class_docstr: Hyperprior architecture (probability model).
class_docstr_tok: ["Hyperprior","architecture","(","probability","model",")","."]
docstr: Apply this layer to code `latents`.
  
  Args:
    latents: Tensor of latent values to code.
    image_shape: The [height, width] of a reference frame.
    mode: The training, evaluation or validation mode of the model.
  
  Returns:
    A HyperInfo tuple.
docstr_tok: ["Apply","this","layer","to","code","`","latents","`",".","Args",":","latents",":","Tensor","of","latent","values","to","code",".","image_shape",":","The","[","height",",","width","]","of","a","reference","frame",".","mode",":","The","training",",","evaluation","or","validation","mode","of","the","model",".","Returns",":","A","HyperInfo","tuple","."]
code: def call(self, latents, image_shape, mode: ModelMode) -> HyperInfo:
      """Apply this layer to code `latents`.
  
      Args:
        latents: Tensor of latent values to code.
        image_shape: The [height, width] of a reference frame.
        mode: The training, evaluation or validation mode of the model.
  
      Returns:
        A HyperInfo tuple.
      """
      training = mode == ModelMode.TRAINING
      validation = mode == ModelMode.VALIDATION
  
      latent_shape = tf.shape(latents)[1:-1]
      hyper_latents = self._analysis(latents, training=training)
  
      # Model hyperprior distributions and entropy encode/decode hyper-latents.
      side_info = self._side_entropy_model(
          hyper_latents,
          image_shape=image_shape,
          mode=mode,
          training=training,
      )
      hyper_decoded = side_info.decoded
  
      scale_table = np.exp(
          np.linspace(
              np.log(SCALES_MIN), np.log(SCALES_MAX), SCALES_LEVELS
          )
      )
  
      latent_scales = self._synthesis_scale(
          hyper_decoded, training=training
      )
      latent_means = self._synthesis_mean(
          tf.cast(hyper_decoded, tf.float32), training=training
      )
  
      if not (training or validation):
          latent_scales = latent_scales[
              :, : latent_shape[0], : latent_shape[1], :
          ]
          latent_means = latent_means[
              :, : latent_shape[0], : latent_shape[1], :
          ]
  
      conditional_entropy_model = tfc.GaussianConditional(
          latent_scales,
          scale_table,
          mean=latent_means,
          name="conditional_entropy_model",
      )
  
      entropy_info = estimate_entropy(
          conditional_entropy_model, latents, spatial_shape=image_shape
      )
  
      compressed = None
      if training:
          latents_decoded = _ste_quantize(latents, latent_means)
      elif validation:
          latents_decoded = entropy_info.quantized
      else:
          compressed = conditional_entropy_model.compress(latents)
          latents_decoded = conditional_entropy_model.decompress(
              compressed
          )
  
      info = HyperInfo(
          decoded=latents_decoded,
          latent_shape=latent_shape,
          hyper_latent_shape=side_info.latent_shape,
          nbpp=entropy_info.nbpp,
          side_nbpp=side_info.total_nbpp,
          total_nbpp=entropy_info.nbpp + side_info.total_nbpp,
          qbpp=entropy_info.qbpp,
          side_qbpp=side_info.total_qbpp,
          total_qbpp=entropy_info.qbpp + side_info.total_qbpp,
          # We put everything that's needed for real arithmetic coding into
          # the bistream_tensors tuple.
          bitstream_tensors=(
              compressed,
              side_info.bitstring,
              image_shape,
              latent_shape,
              side_info.latent_shape,
          ),
      )
  
      tf.summary.scalar("bpp/total/noisy", info.total_nbpp)
      tf.summary.scalar("bpp/total/quantized", info.total_qbpp)
  
      tf.summary.scalar("bpp/latent/noisy", entropy_info.nbpp)
      tf.summary.scalar("bpp/latent/quantized", entropy_info.qbpp)
  
      tf.summary.scalar("bpp/side/noisy", side_info.total_nbpp)
      tf.summary.scalar("bpp/side/quantized", side_info.total_qbpp)
  
      return info
  
imports: import collections
  from compare_gan.architectures import abstract_arch
  from compare_gan.architectures import arch_ops
  import numpy
  import tensorflow.compat.v1
  import tensorflow_compression
  from hific.helpers import ModelMode
label_desc: Use image node_id 6 for calling the Hyperprior obj's underlying member method code with example usage: obj.call(latents, image_shape, mode) and returns: info