class_docstr: Entropy model for power-law distributed random variables.
  
  This entropy model handles quantization and compression of a bottleneck tensor
  and implements a penalty that encourages compressibility under the Elias gamma
  code.
  
  The gamma code has code lengths `1 + 2 floor(log_2(x))`, for `x` a positive
  integer, and is close to optimal if `x` is distributed according to a power
  law. Being a universal code, it also guarantees that in the worst case, the
  expected code length is no more than 3 times the entropy of the empirical
  distribution of `x`, as long as probability decreases with increasing `x`. For
  details on the gamma code, see:
  
  > "Universal Codeword Sets and Representations of the Integers"<br />
  > P. Elias<br />
  > https://doi.org/10.1109/TIT.1975.1055349
  
  Given a signed integer, `run_length_gamma_encode` encodes zeros using a
  run-length code, the sign using a uniform bit, and applies the gamma code to
  the magnitude.
  
  The penalty applied by this class is given by:
  ```
  log((abs(x) + alpha) / alpha)
  ```
  This encourages `x` to follow a symmetrized power law, but only approximately
  for `alpha > 0`. Without `alpha`, the penalty would have a singularity at
  zero. Setting `alpha` to a small positive value ensures that the penalty is
  non-negative, and that its gradients are useful for optimization.
docstr: Initializes the instance.
  
  Args:
    coding_rank: Integer. Number of innermost dimensions considered a coding
      unit. Each coding unit is compressed to its own bit string, and the
      estimated rate is summed over each coding unit in `bits()`.
    alpha: Float. Regularization parameter preventing gradient singularity
      around zero.
    bottleneck_dtype: `tf.dtypes.DType`. Data type of bottleneck tensor.
      Defaults to `tf.keras.mixed_precision.global_policy().compute_dtype`.
docstr_tok: ["Initializes","the","instance",".","Args",":","coding_rank",":","Integer",".","Number","of","innermost","dimensions","considered","a","coding","unit",".","Each","coding","unit","is","compressed","to","its","own","bit","string",",","and","the","estimated","rate","is","summed","over","each","coding","unit","in","`","bits","(",")","`",".","alpha",":","Float",".","Regularization","parameter","preventing","gradient","singularity","around","zero",".","bottleneck_dtype",":","`","tf.dtypes.DType","`",".","Data","type","of","bottleneck","tensor",".","Defaults","to","`","tf.keras.mixed_precision.global_policy","(",")",".compute_dtype","`","."]
code: def __init__(self, coding_rank, alpha=1e-2, bottleneck_dtype=None):
      """Initializes the instance.
  
      Args:
        coding_rank: Integer. Number of innermost dimensions considered a coding
          unit. Each coding unit is compressed to its own bit string, and the
          estimated rate is summed over each coding unit in `bits()`.
        alpha: Float. Regularization parameter preventing gradient singularity
          around zero.
        bottleneck_dtype: `tf.dtypes.DType`. Data type of bottleneck tensor.
          Defaults to `tf.keras.mixed_precision.global_policy().compute_dtype`.
      """
      self._coding_rank = int(coding_rank)
      if self.coding_rank < 0:
          raise ValueError("`coding_rank` must be at least 0.")
      self._alpha = float(alpha)
      if self.alpha <= 0:
          raise ValueError("`alpha` must be greater than 0.")
      if bottleneck_dtype is None:
          bottleneck_dtype = (
              tf.keras.mixed_precision.global_policy().compute_dtype
          )
      if bottleneck_dtype is None:
          bottleneck_dtype = tf.keras.backend.floatx()
      self._bottleneck_dtype = tf.as_dtype(bottleneck_dtype)
      super().__init__()
  
file_path: compression/tensorflow_compression/python/entropy_models/power_law.py
imports: import tensorflow
  from tensorflow_compression.python.ops import gen_ops
  from tensorflow_compression.python.ops import round_ops
label_desc: Use image node_id 1 to create a new PowerLawEntropyModel object from inherited base classes: tf with example: obj = PowerLawEntropyModel(coding_rank, alpha, bottleneck_dtype)