class_docstr: Encoding stage performing uniform quantization.
  
  This class performs quantization to uniformly spaced values, without realizing
  any savings by itself.
  
  In particular, given a floating point input `x` to the `encode` method, the
  output will have the same `dtype` as `x`, with values being "floating point
  integers" in the range `[0, 2**bits-1]`.
  
  If `min_max` is not provided, the extreme points of the quantized interval
  will correspond to the min and max values of the input `x`. If `min_max` is
  provided, the input `x` is first clipped to this range, and the extreme points
  of the quantized interval correspond to the provided `min_max` values.
class_docstr_tok: ["Encoding","stage","performing","uniform","quantization",".","This","class","performs","quantization","to","uniformly","spaced","values",",","without","realizing","any","savings","by","itself",".","In","particular",",","given","a","floating","point","input","`","x","`","to","the","`","encode","`","method",",","the","output","will","have","the","same","`","dtype","`","as","`","x","`",",","with","values","being","``","floating","point","integers","''","in","the","range","`","[","0",",","2","*","*","bits-1","]","`",".","If","`","min_max","`","is","not","provided",",","the","extreme","points","of","the","quantized","interval","will","correspond","to","the","min","and","max","values","of","the","input","`","x","`",".","If","`","min_max","`","is","provided",",","the","input","`","x","`","is","first","clipped","to","this","range",",","and","the","extreme","points","of","the","quantized","interval","correspond","to","the","provided","`","min_max","`","values","."]
docstr: Initializer for the UniformQuantizationEncodingStage.
  
  Args:
    bits: The number of bits to quantize to. Must be an integer between 1 and
      16. Can be either a TensorFlow or a Python value.
    min_max: A range to be used for quantization. If `None`, the range of the
      vector to be encoded will be used. If provided, must be an array of 2
      elements, corresponding to the min and max value, respectively. Can be
      either a TensorFlow or a Python value.
    stochastic: A Python bool, whether to use stochastic or deterministic
      rounding. If `True`, the encoding is randomized and on expectation
      unbiased. If `False`, the encoding is deterministic.
    **kwargs: Keyword arguments.
  
  Raises:
    ValueError: The inputs do not satisfy the above constraints.
code: def __init__(self, bits=8, min_max=None, stochastic=True, **kwargs):
      """Initializer for the UniformQuantizationEncodingStage.
  
      Args:
        bits: The number of bits to quantize to. Must be an integer between 1 and
          16. Can be either a TensorFlow or a Python value.
        min_max: A range to be used for quantization. If `None`, the range of the
          vector to be encoded will be used. If provided, must be an array of 2
          elements, corresponding to the min and max value, respectively. Can be
          either a TensorFlow or a Python value.
        stochastic: A Python bool, whether to use stochastic or deterministic
          rounding. If `True`, the encoding is randomized and on expectation
          unbiased. If `False`, the encoding is deterministic.
        **kwargs: Keyword arguments.
  
      Raises:
        ValueError: The inputs do not satisfy the above constraints.
      """
      if not tf.is_tensor(bits) and bits not in self._ALLOWED_BITS_ARG:
          raise ValueError(
              "The bits argument must be an integer between 1 and 16."
          )
      self._bits = bits
  
      if min_max is not None:
          if tf.is_tensor(min_max):
              if min_max.shape.as_list() != [2]:
                  raise ValueError(
                      "The min_max argument must be Tensor with shape (2)."
                  )
          else:
              if not isinstance(min_max, list) or len(min_max) != 2:
                  raise ValueError(
                      "The min_max argument must be a list with two elements."
                  )
              if min_max[0] >= min_max[1]:
                  raise ValueError(
                      "The first element of the min_max argument must be "
                      "smaller than the second element."
                  )
      self._min_max = min_max
  
      if not isinstance(stochastic, bool):
          raise TypeError("The stochastic argument must be a bool.")
      self._stochastic = stochastic
      self._force_random_op_after_clipping = kwargs.get(
          "reduce_memory_use_by_forcing_random_op_after_clipping", False
      )
  
imports: import collections
  import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.core import encoding_stage
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.utils import tf_utils
label_desc: Use image node_id 1 to create a new UniformQuantizationEncodingStage object from inherited base classes: encoding_stage with example: obj = UniformQuantizationEncodingStage(bits, min_max, stochastic)