class_docstr: Lossless compression for Herarchical latent variable models.
  
  Based on the Craystack (https://github.com/j-towns/craystack)
  implementation of Bits-Back coding.
  
  Args:
      model: The hierarchical latent variable model.
      data_shape: The shape [batch-size, channels, height, width]
          of the data and each latent.
      latent_prec: Coding precision.
      prior_prec: Precision for the discretization.
      obs_prec: Precision for the observation codec.
      data_prec: Precision of the discrete data.
      initial_len: Length of the random initial bitstring.
      data_min: Minimum value of the data to be fed into the model.
      data_max: Maximum value of the data to be fed into the model.
      clip_stdd: Minimum value for the stdd of the observation codec.
      track: Whether to track the message sizes at each step.
class_docstr_tok: ["Lossless","compression","for","Herarchical","latent","variable","models",".","Based","on","the","Craystack","(","https",":","\/\/github.com\/j-towns\/craystack",")","implementation","of","Bits-Back","coding",".","Args",":","model",":","The","hierarchical","latent","variable","model",".","data_shape",":","The","shape","[","batch-size",",","channels",",","height",",","width","]","of","the","data","and","each","latent",".","latent_prec",":","Coding","precision",".","prior_prec",":","Precision","for","the","discretization",".","obs_prec",":","Precision","for","the","observation","codec",".","data_prec",":","Precision","of","the","discrete","data",".","initial_len",":","Length","of","the","random","initial","bitstring",".","data_min",":","Minimum","value","of","the","data","to","be","fed","into","the","model",".","data_max",":","Maximum","value","of","the","data","to","be","fed","into","the","model",".","clip_stdd",":","Minimum","value","for","the","stdd","of","the","observation","codec",".","track",":","Whether","to","track","the","message","sizes","at","each","step","."]
docstr: Pop indices idx_{steps-1}, ..., idx_1 top-down
  using a uniform distribution.
  
  Indices idx_{steps} correspond to bins having equal mass under the
  Gaussian priors p(z_{step}|z_{steps+1}) or p(z_{steps-1}) and
  (discretized) latent variables z_{step} are given by the median
  of the corresponding bin.
  
  Args:
      message: The craystack message to pop from.
  Returns:
      A tuple containing the new craystack message and the popped indices.
docstr_tok: ["Pop","indices","idx_","{","steps-1","}",",","...",",","idx_1","top-down","using","a","uniform","distribution",".","Indices","idx_","{","steps","}","correspond","to","bins","having","equal","mass","under","the","Gaussian","priors","p","(","z_","{","step","}","|z_","{","steps+1","}",")","or","p","(","z_","{","steps-1","}",")","and","(","discretized",")","latent","variables","z_","{","step","}","are","given","by","the","median","of","the","corresponding","bin",".","Args",":","message",":","The","craystack","message","to","pop","from",".","Returns",":","A","tuple","containing","the","new","craystack","message","and","the","popped","indices","."]
code: def prior_pop(
      self, message: tuple
  ) -> Tuple[tuple, List[DiscrLatent]]:
      """
      Pop indices idx_{steps-1}, ..., idx_1 top-down
      using a uniform distribution.
  
      Indices idx_{steps} correspond to bins having equal mass under the
      Gaussian priors p(z_{step}|z_{steps+1}) or p(z_{steps-1}) and
      (discretized) latent variables z_{step} are given by the median
      of the corresponding bin.
  
      Args:
          message: The craystack message to pop from.
      Returns:
          A tuple containing the new craystack message and the popped indices.
      """
      discr_latents: List[DiscrLatent] = []
      for step in range(self.model.steps, 0, -1):
          if step == self.model.steps:
              prior_params = GaussianParams(
                  mean=np.zeros(self.data_shape),
                  stdd=np.ones(self.data_shape),
              )
          else:
              latent = self._to_latent(discr_latents[-1])
              prior_params = self.model.generate_fn(latent, step)
  
          codec = self._track_codec(self.prior_codec, step=step)
          message, latent_inds = codec.pop(message)
          discr_latents.append(
              DiscrLatent(inds=latent_inds, params=prior_params)
          )
      return message, discr_latents[::-1]
  
imports: from abc import ABC, abstractmethod
  from typing import List, NamedTuple, Optional, Tuple, Union, overload
  import craystack
  import numpy
  import torch
  from craystack import codecs
  from craystack.bb_ans import BBANS
  from improved_diffusion.gaussian_diffusion import GaussianDiffusion
label_desc: Use image node_id 11 for calling the BitsBackCodec obj's underlying member method code with example usage: obj.prior_pop(message) and returns: message,  discr_latents