class_docstr: Nonlinear transform coding model.
docstr: Initializer.
  
  Args:
    analysis: A `Layer` object implementing the analysis transform.
    synthesis: A `Layer` object implementing the synthesis transform.
    prior_type: String. Either 'deep' for `DeepFactorized` prior, or
      'gsm/gmm/lsm/lmm-X' for Gaussian/Logistic Scale Mixture/Mixture Model
      with X components.
    dither: Sequence of 4 Booleans. Whether to use dither for: rate term
      during training, distortion term during training, rate term during
      testing, distortion term during testing, respectively.
    soft_round: Sequence of 2 Booleans. Whether to use soft rounding during
      training or testing, respectively.
    guess_offset: Boolean. When not using soft rounding, whether to use the
      mode centering heuristic to determine the quantization offset during
      testing.
    **kwargs: Other arguments passed through to `CompressionModel` class.
docstr_tok: ["Initializer",".","Args",":","analysis",":","A","`","Layer","`","object","implementing","the","analysis","transform",".","synthesis",":","A","`","Layer","`","object","implementing","the","synthesis","transform",".","prior_type",":","String",".","Either","'deep","'","for","`","DeepFactorized","`","prior",",","or","'gsm\/gmm\/lsm\/lmm-X","'","for","Gaussian\/Logistic","Scale","Mixture\/Mixture","Model","with","X","components",".","dither",":","Sequence","of","4","Booleans",".","Whether","to","use","dither","for",":","rate","term","during","training",",","distortion","term","during","training",",","rate","term","during","testing",",","distortion","term","during","testing",",","respectively",".","soft_round",":","Sequence","of","2","Booleans",".","Whether","to","use","soft","rounding","during","training","or","testing",",","respectively",".","guess_offset",":","Boolean",".","When","not","using","soft","rounding",",","whether","to","use","the","mode","centering","heuristic","to","determine","the","quantization","offset","during","testing",".","*","*","kwargs",":","Other","arguments","passed","through","to","`","CompressionModel","`","class","."]
code: def __init__(
      self,
      analysis,
      synthesis,
      prior_type="deep",
      dither=(1, 1, 0, 0),
      soft_round=(1, 0),
      guess_offset=False,
      **kwargs,
  ):
      """Initializer.
  
      Args:
        analysis: A `Layer` object implementing the analysis transform.
        synthesis: A `Layer` object implementing the synthesis transform.
        prior_type: String. Either 'deep' for `DeepFactorized` prior, or
          'gsm/gmm/lsm/lmm-X' for Gaussian/Logistic Scale Mixture/Mixture Model
          with X components.
        dither: Sequence of 4 Booleans. Whether to use dither for: rate term
          during training, distortion term during training, rate term during
          testing, distortion term during testing, respectively.
        soft_round: Sequence of 2 Booleans. Whether to use soft rounding during
          training or testing, respectively.
        guess_offset: Boolean. When not using soft rounding, whether to use the
          mode centering heuristic to determine the quantization offset during
          testing.
        **kwargs: Other arguments passed through to `CompressionModel` class.
      """
      super().__init__(**kwargs)
      self._analysis = analysis
      self._synthesis = synthesis
      self.prior_type = str(prior_type)
      self.dither = tuple(bool(i) for i in dither)
      self.soft_round = tuple(bool(i) for i in soft_round)
      self.guess_offset = bool(guess_offset)
  
      if self.prior_type == "deep":
          self._prior = tfc.DeepFactorized(
              batch_shape=[self.ndim_latent], dtype=self.dtype
          )
      elif self.prior_type[:4] in ("gsm-", "gmm-", "lsm-", "lmm-"):
          components = int(self.prior_type[4:])
          shape = (self.ndim_latent, components)
          self.logits = tf.Variable(
              tf.random.normal(shape, dtype=self.dtype)
          )
          self.log_scale = tf.Variable(
              tf.random.normal(shape, mean=2.0, dtype=self.dtype)
          )
          if "s" in self.prior_type:
              self.loc = 0.0
          else:
              self.loc = tf.Variable(
                  tf.random.normal(shape, dtype=self.dtype)
              )
      else:
          raise ValueError(f"Unknown prior_type: '{prior_type}'.")
  
      self._logit_alpha = tf.Variable(
          -3, dtype=self.dtype, name="logit_alpha"
      )
      self._force_alpha = tf.Variable(
          -1, trainable=False, dtype=self.dtype, name="force_alpha"
      )
  
imports: import matplotlib.pyplot
  import numpy
  import tensorflow
  import tensorflow_compression
  import tensorflow_probability
  from toy_sources import compression_model
label_desc: Use image node_id 1 to create a new NTCModel object from inherited base classes: compression_model with example: obj = NTCModel(analysis, synthesis, prior_type, dither, soft_round, guess_offset)