class_docstr: Entropy model for Laplace distributed random variables.
  
  This entropy model handles quantization and compression of a bottleneck tensor
  and implements a penalty that encourages compressibility under the Rice
  code.
  
  Given a signed integer, `run_length_encode` encodes zeros using a
  run-length code, the sign using a uniform bit, and applies the Rice code to
  the magnitude.
  
  The penalty applied by this class is given by:
  ```
  l1 * reduce_sum(abs(x))
  ```
  This encourages `x` to follow a symmetrized laplace distribution.
class_docstr_tok: ["Entropy","model","for","Laplace","distributed","random","variables",".","This","entropy","model","handles","quantization","and","compression","of","a","bottleneck","tensor","and","implements","a","penalty","that","encourages","compressibility","under","the","Rice","code",".","Given","a","signed","integer",",","`","run_length_encode","`","encodes","zeros","using","a","run-length","code",",","the","sign","using","a","uniform","bit",",","and","applies","the","Rice","code","to","the","magnitude",".","The","penalty","applied","by","this","class","is","given","by",":","``","`","l1","*","reduce_sum","(","abs","(","x",")",")","``","`","This","encourages","`","x","`","to","follow","a","symmetrized","laplace","distribution","."]
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()`.
    l1: Float. L1 regularization factor.
    run_length_code: Int. Rice code if >= 0 else Gamma code.
    magnitude_code: Int. Rice code if >= 0 else Gamma code.
    use_run_length_for_non_zeros: Bool. Whether to encode nonzero run lengths.
    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","(",")","`",".","l1",":","Float",".","L1","regularization","factor",".","run_length_code",":","Int",".","Rice","code","if",">","=","0","else","Gamma","code",".","magnitude_code",":","Int",".","Rice","code","if",">","=","0","else","Gamma","code",".","use_run_length_for_non_zeros",":","Bool",".","Whether","to","encode","nonzero","run","lengths",".","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,
      l1=0.01,
      run_length_code=-1,
      magnitude_code=0,
      use_run_length_for_non_zeros=False,
      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()`.
        l1: Float. L1 regularization factor.
        run_length_code: Int. Rice code if >= 0 else Gamma code.
        magnitude_code: Int. Rice code if >= 0 else Gamma code.
        use_run_length_for_non_zeros: Bool. Whether to encode nonzero run lengths.
        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._l1 = float(l1)
      if self.l1 <= 0:
          raise ValueError("`l1` must be greater than 0.")
      self._run_length_code = run_length_code
      self._magnitude_code = magnitude_code
      self._use_run_length_for_non_zeros = use_run_length_for_non_zeros
      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/laplace.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 LaplaceEntropyModel object from inherited base classes: tf with example: obj = LaplaceEntropyModel(coding_rank, l1, run_length_code, magnitude_code, use_run_length_for_non_zeros, bottleneck_dtype)