class_docstr: Abstract base class (ABC) for continuous entropy layers
  
  This base class pre-computes integer probability tables based on a prior
  distribution, which can be used across different platforms by a range
  encoder and decoder.
  
  Args:
      coding_rank: Number of innermost dimensions considered a coding unit.
          Each coding unit is compressed to its own bit string. The coding
          units are summed during propagation.
      compressible: If ``True``, the integer probability tables used by the
          ``compress()`` and ``decompress()`` methods will be instantiated.
          If ``False``, these two methods are inaccessible.
      stateless: If ``True``, creates range coding tables as ``Tensor``s.
          This makes the entropy model stateless and the range coding tables
          are expected to be provided manually. If ``compressible`` is
          ``False``, then it is implied ``stateless`` is ``True`` and the
          provided ``stateless`` value is ignored. If ``False``, range coding
          tables are persisted as ``Parameter``s. This allows the entropy
          model to be serialized, so both the range encoder and decoder use
          identical tables when loading the stored model.
      prior: A probability density function fitting the marginal
          distribution of the bottleneck data with additive uniform noise,
          which is shared a priori between the sender and the receiver. For
          best results, the distribution should be flexible enough to have a
          unit-width uniform distribution as a special case, since this is
          the marginal distribution for bottleneck dimensions that are
          constant.
      tail_mass: An approximate probability mass which is range encoded with
          less precision, by using a Golomb-like code.
      prior_dtype: The data type of the prior. Must be provided when
          ``prior`` is omitted.
      prior_shape: The batch shape of the prior, i.e. dimensions which are
          not assumed identically distributed (i.i.d.). Must be provided when
          ``prior`` is omitted.
      range_coder_precision: The precision passed to ``range_encoder`` and
          ``range_decoder``.
      cdfs: If provided, used for range coding rather than the probability
          tables built from ``prior``.
      cdf_sizes: Must be provided alongside ``cdfs``.
      cdf_offsets: Must be provided alongside ``cdfs``.
      maximum_cdf_size: The maximum ``cdf_sizes``. When provided, an empty
          range coding table is created, which can then be restored. Requires
          ``compressible`` to be ``True`` and ``stateless`` to be ``False``.
class_docstr_tok: ["Abstract","base","class","(","ABC",")","for","continuous","entropy","layers","This","base","class","pre-computes","integer","probability","tables","based","on","a","prior","distribution",",","which","can","be","used","across","different","platforms","by","a","range","encoder","and","decoder",".","Args",":","coding_rank",":","Number","of","innermost","dimensions","considered","a","coding","unit",".","Each","coding","unit","is","compressed","to","its","own","bit","string",".","The","coding","units","are","summed","during","propagation",".","compressible",":","If","``","True","``",",","the","integer","probability","tables","used","by","the","``","compress","(",")","``","and","``","decompress","(",")","``","methods","will","be","instantiated",".","If","``","False","``",",","these","two","methods","are","inaccessible",".","stateless",":","If","``","True","``",",","creates","range","coding","tables","as","``","Tensor","``","s",".","This","makes","the","entropy","model","stateless","and","the","range","coding","tables","are","expected","to","be","provided","manually",".","If","``","compressible","``","is","``","False","``",",","then","it","is","implied","``","stateless","``","is","``","True","``","and","the","provided","``","stateless","``","value","is","ignored",".","If","``","False","``",",","range","coding","tables","are","persisted","as","``","Parameter","``","s",".","This","allows","the","entropy","model","to","be","serialized",",","so","both","the","range","encoder","and","decoder","use","identical","tables","when","loading","the","stored","model",".","prior",":","A","probability","density","function","fitting","the","marginal","distribution","of","the","bottleneck","data","with","additive","uniform","noise",",","which","is","shared","a","priori","between","the","sender","and","the","receiver",".","For","best","results",",","the","distribution","should","be","flexible","enough","to","have","a","unit-width","uniform","distribution","as","a","special","case",",","since","this","is","the","marginal","distribution","for","bottleneck","dimensions","that","are","constant",".","tail_mass",":","An","approximate","probability","mass","which","is","range","encoded","with","less","precision",",","by","using","a","Golomb-like","code",".","prior_dtype",":","The","data","type","of","the","prior",".","Must","be","provided","when","``","prior","``","is","omitted",".","prior_shape",":","The","batch","shape","of","the","prior",",","i.e",".","dimensions","which","are","not","assumed","identically","distributed","(","i.i.d.",")",".","Must","be","provided","when","``","prior","``","is","omitted",".","range_coder_precision",":","The","precision","passed","to","``","range_encoder","``","and","``","range_decoder","``",".","cdfs",":","If","provided",",","used","for","range","coding","rather","than","the","probability","tables","built","from","``","prior","``",".","cdf_sizes",":","Must","be","provided","alongside","``","cdfs","``",".","cdf_offsets",":","Must","be","provided","alongside","``","cdfs","``",".","maximum_cdf_size",":","The","maximum","``","cdf_sizes","``",".","When","provided",",","an","empty","range","coding","table","is","created",",","which","can","then","be","restored",".","Requires","``","compressible","``","to","be","``","True","``","and","``","stateless","``","to","be","``","False","``","."]
docstr: Quantizes a floating-point ``Tensor``.
  
  To use this entropy layer as an information bottleneck during training,
  pass a ``Tensor`` to this function. The ``Tensor`` is rounded to
  integer values modulo a quantization offset, which depends on
  ``indexes``. For example, for a ``Normal`` distribution, the returned
  values are rounded to the location of the mode of the distributions
  plus or minus an integer.
  
  The gradient of this rounding operation is overridden with the identity
  (straight-through gradient estimator).
  
  Args:
      bottleneck: the data to be quantized.
      indexes: the scalar distribution for each element in
          ``bottleneck``.
      offsets:
  
  Returns:
      the quantized values.
docstr_tok: ["Quantizes","a","floating-point","``","Tensor","``",".","To","use","this","entropy","layer","as","an","information","bottleneck","during","training",",","pass","a","``","Tensor","``","to","this","function",".","The","``","Tensor","``","is","rounded","to","integer","values","modulo","a","quantization","offset",",","which","depends","on","``","indexes","``",".","For","example",",","for","a","``","Normal","``","distribution",",","the","returned","values","are","rounded","to","the","location","of","the","mode","of","the","distributions","plus","or","minus","an","integer",".","The","gradient","of","this","rounding","operation","is","overridden","with","the","identity","(","straight-through","gradient","estimator",")",".","Args",":","bottleneck",":","the","data","to","be","quantized",".","indexes",":","the","scalar","distribution","for","each","element","in","``","bottleneck","``",".","offsets",":","Returns",":","the","quantized","values","."]
code: def quantize(
      bottleneck: Tensor,
      indexes: Tensor,
      offsets: Optional[Tensor] = None,
  ) -> IntTensor:
      """Quantizes a floating-point ``Tensor``.
  
      To use this entropy layer as an information bottleneck during training,
      pass a ``Tensor`` to this function. The ``Tensor`` is rounded to
      integer values modulo a quantization offset, which depends on
      ``indexes``. For example, for a ``Normal`` distribution, the returned
      values are rounded to the location of the mode of the distributions
      plus or minus an integer.
  
      The gradient of this rounding operation is overridden with the identity
      (straight-through gradient estimator).
  
      Args:
          bottleneck: the data to be quantized.
          indexes: the scalar distribution for each element in
              ``bottleneck``.
          offsets:
  
      Returns:
          the quantized values.
      """
      outputs = bottleneck.clone()
  
      if offsets is not None:
          outputs = outputs - offsets
  
      outputs = torch.round(outputs)
  
      return IntTensor(outputs)
  
imports: import abc
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn
  from compressai.entropy_models.entropy_models import pmf_to_quantized_cdf
  from torch import IntTensor, Size, Tensor
  from torch.distributions import Distribution
  from torch.nn import Module
  import neuralcompression.functional
  from neuralcompression.distributions import UniformNoise
label_desc: Use image node_id 17 for calling the ContinuousEntropy obj's underlying member method code with example usage: obj.quantize(bottleneck, indexes, offsets) and returns: IntTensor