# tff.learning.metrics.create_default_secure_sum_quantization_ranges

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Create a nested structure of quantization ranges for secure sum encoding.

    tff.learning.metrics.create_default_secure_sum_quantization_ranges(
        local_unfinalized_metrics_type: https://www.tensorflow.org/federated/api_docs/python/tff/types/StructWithPythonType,
        lower_bound: Union[int, float] = DEFAULT_FIXED_SECURE_LOWER_BOUND,
        upper_bound: Union[int, float] = DEFAULT_FIXED_SECURE_UPPER_BOUND,
        use_auto_tuned_bounds_for_float_values: Optional[bool] = True
    ) -> MetricValueRangeDict

<br />

<br />

<br />

| ## Args ||
|---|---|
| `local_unfinalized_metrics_type` | The [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) structure to generate default secure sum quantization ranges form. Must be a [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) tree containing only [`tff.TensorType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/TensorType) and [`tff.StructType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/StructType). Each [`tff.TensorType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/TensorType) must be of floating point or integer dtype. |
| `lower_bound` | An optional integer or floating point lower bound for the secure sum quantization range. Values smaller than this will be clipped to this value. By default is `0`. If a `float`, any [`tff.TensorType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/TensorType) in `local_unfinalized_metrics_type` with an integer dtype will use [`math.ceil(lower_bound)`](https://www.tensorflow.org/api_docs/python/tfm/optimization/math/ceil) as a bound. |
| `upper_bound` | An optional integer or floating point upper bound for the secure sum quantization range. Values larger than this will be clipped to this value. By default is `2^20 - 1` (\~1 million). If a `float`, any [`tff.TensorType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/TensorType) in `local_unfinalized_metrics_type` with an integer dtype will use [`math.floor(lower_bound)`](https://www.tensorflow.org/api_docs/python/tfm/optimization/math/floor) as a bound. |
| `use_auto_tuned_bounds_for_float_values` | An optional boolean for specifying whether to use auto-tuned bounds for float values. If True, a default [`tff.templates.EstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess) is used for `upper_bound`, and the `lower_bound` is None to allow [`tff.aggregators.SecureSumFactory`](https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/SecureSumFactory) to determine the `lower_bound`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A nested structure matching the structure of `local_unfinalized_metrics_type` where each `tf.TensorType` has been replaced with a 2-tuple of lower bound and upper bound, where the tuple can be (`float`, `float`) or (None, [`tff.templates.EstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess)) for floating dtypes, and (`int`, `int`) for integer dtypes. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `UnquantizableDTypeError` | If A [`tff.TensorType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/TensorType) in `local_unfinalized_metrics_type` has a non-float or non-integer dtype. |
| `ValueError` | If an integer dtype in `local_unfinalized_metrics_type` will have a zero range (e.g. `math.ceil(lower_bound) - math.floor(upper_bound) < 1`). |

<br />