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","``","."]
code: def __init__(
      self,
      coding_rank: Optional[int] = None,
      compressible: bool = False,
      stateless: bool = False,
      prior: Optional[Union[Distribution, UniformNoise]] = None,
      tail_mass: float = 2**-8,
      prior_shape: Optional[Tuple[int, ...]] = None,
      prior_dtype: Optional[torch.dtype] = None,
      cdfs: Optional[IntTensor] = None,
      cdf_sizes: Optional[IntTensor] = None,
      cdf_offsets: Optional[IntTensor] = None,
      maximum_cdf_size: Optional[int] = None,
      range_coder_precision: int = 12,
  ):
      super(ContinuousEntropy, self).__init__()
  
      self._coding_rank = coding_rank
  
      self._compressible = compressible
  
      self._stateless = stateless
  
      self._tail_mass = tail_mass
  
      self._range_coder_precision = range_coder_precision
  
      if prior is None:
          if prior_shape is None or prior_dtype is None:
              error_message = r"""either `prior` or both `prior_dtype` and
                  `prior_shape` must be provided
                  """
  
              raise ValueError(error_message)
  
          self._prior_shape = Size(prior_shape)
          self._prior_dtype = prior_dtype
      else:
          self._prior_shape = prior.batch_shape
          self._prior_dtype = torch.float32
  
      if self.compressible:
          if (
              not (cdfs is None)
              == (cdf_sizes is None)
              == (cdf_offsets is None)
          ):
              error_message = r"""either all or none of the cumulative
                  distribution function (CDF) arguments (`cdfs`, `cdf_offsets`,
                  `cdf_sizes`, and `maximum_cdf_size`) must be provided
                  """
  
              raise ValueError(error_message)
  
          if (prior is None) + (maximum_cdf_size is None) + (
              cdfs is None
          ) != 2:
              error_message = r"""when `compressible` is `True`, exactly one
                  of `prior`, `cdfs`, or `maximum_cdf_size` must be provided.
                  """
  
              raise ValueError(error_message)
  
          if prior is not None:
              self._prior = prior
  
              cdfs, cdf_sizes, cdf_offsets = self._update()
          elif maximum_cdf_size is not None:
              if self.stateless:
                  error_message = r"""if `stateless` is `True`, cannot
                      provide `maximum_cdf_size`
                      """
  
                  raise ValueError(error_message)
  
              context_size = len(self.context_shape)
  
              zeros = torch.zeros(
                  [context_size, maximum_cdf_size],
                  dtype=torch.int32,
              )
  
              cdfs = IntTensor(zeros)
  
              cdf_offsets = IntTensor(zeros[0, :])
              cdf_sizes = IntTensor(zeros[0, :])
      else:
          if not (
              cdfs is None
              and cdf_offsets is None
              and cdf_sizes is None
              and maximum_cdf_size is None
          ):
              error_message = r"""cumulative distribution function (CDF)
                  arguments (`cdfs`, `cdf_offsets`, `cdf_sizes`, and
                  `maximum_cdf_size`) cannot be provided when `compressible` is
                  `False`
                  """
  
              raise ValueError(error_message)
  
      self.register_buffer("_cdfs", cdfs)
      self.register_buffer("_cdf_sizes", cdf_sizes)
      self.register_buffer("_cdf_offsets", cdf_offsets)
  
      self._maximum_cdf_size = maximum_cdf_size
  
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 1 to create a new ContinuousEntropy object from inherited base classes: Module with example: obj = ContinuousEntropy(coding_rank, compressible, stateless, prior, tail_mass, prior_shape, prior_dtype, cdfs, cdf_sizes, cdf_offsets, maximum_cdf_size, range_coder_precision)