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: Compresses a floating-point tensor.
  
  Compresses the tensor to bit strings. `bottleneck` is first quantized
  as in `quantize()`, and then compressed using the run-length rice code. The
  quantized tensor can later be recovered by calling `decompress()`.
  
  The innermost `self.coding_rank` dimensions are treated as one coding unit,
  i.e. are compressed into one string each. Any additional dimensions to the
  left are treated as batch dimensions.
  
  Args:
    bottleneck: `tf.Tensor` containing the data to be compressed. Must have at
      least `self.coding_rank` dimensions.
  
  Returns:
    A `tf.Tensor` having the same shape as `bottleneck` without the
    `self.coding_rank` innermost dimensions, containing a string for each
    coding unit.
docstr_tok: ["Compresses","a","floating-point","tensor",".","Compresses","the","tensor","to","bit","strings",".","`","bottleneck","`","is","first","quantized","as","in","`","quantize","(",")","`",",","and","then","compressed","using","the","run-length","rice","code",".","The","quantized","tensor","can","later","be","recovered","by","calling","`","decompress","(",")","`",".","The","innermost","`","self.coding_rank","`","dimensions","are","treated","as","one","coding","unit",",","i.e",".","are","compressed","into","one","string","each",".","Any","additional","dimensions","to","the","left","are","treated","as","batch","dimensions",".","Args",":","bottleneck",":","`","tf.Tensor","`","containing","the","data","to","be","compressed",".","Must","have","at","least","`","self.coding_rank","`","dimensions",".","Returns",":","A","`","tf.Tensor","`","having","the","same","shape","as","`","bottleneck","`","without","the","`","self.coding_rank","`","innermost","dimensions",",","containing","a","string","for","each","coding","unit","."]
code: def compress(self, bottleneck):
      """Compresses a floating-point tensor.
  
      Compresses the tensor to bit strings. `bottleneck` is first quantized
      as in `quantize()`, and then compressed using the run-length rice code. The
      quantized tensor can later be recovered by calling `decompress()`.
  
      The innermost `self.coding_rank` dimensions are treated as one coding unit,
      i.e. are compressed into one string each. Any additional dimensions to the
      left are treated as batch dimensions.
  
      Args:
        bottleneck: `tf.Tensor` containing the data to be compressed. Must have at
          least `self.coding_rank` dimensions.
  
      Returns:
        A `tf.Tensor` having the same shape as `bottleneck` without the
        `self.coding_rank` innermost dimensions, containing a string for each
        coding unit.
      """
      bottleneck = tf.convert_to_tensor(
          bottleneck, dtype=self.bottleneck_dtype
      )
  
      shape = tf.shape(bottleneck)
      if self.coding_rank == 0:
          flat_shape = [-1]
          strings_shape = shape
      else:
          flat_shape = tf.concat([[-1], shape[-self.coding_rank :]], 0)
          strings_shape = shape[: -self.coding_rank]
  
      symbols = tf.cast(tf.round(bottleneck), tf.int32)
      symbols = tf.reshape(symbols, flat_shape)
  
      strings = tf.map_fn(
          self.encode_fn,
          symbols,
          fn_output_signature=tf.TensorSpec((), dtype=tf.string),
      )
      return tf.reshape(strings, strings_shape)
  
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 13 for calling the LaplaceEntropyModel obj's underlying member method code with example usage: obj.compress(bottleneck) and returns: tf