class_docstr: Base class for hierarchical latent variable models.
  
  We assume that the model is of the form
  
  z_{steps-1} -> z_{steps-2} -> ... -> z_0 -> data,
  
  where
  
  1) all variables have the same dims [batch-size, channels, height, width],
  2) p(z_{step}|z_{step+1}), q(z_{step}|z_{step+1}, data), q(z_{steps-1}|data)
      are Gaussians with diagonal covariance matrix,
  3) p(z_{steps-1}) is a standard normal.
  
  Args:
      steps: The number of steps/hierarchchies.
class_docstr_tok: ["Base","class","for","hierarchical","latent","variable","models",".","We","assume","that","the","model","is","of","the","form","z_","{","steps-1","}","-",">","z_","{","steps-2","}","-",">","...","-",">","z_0","-",">","data",",","where","1",")","all","variables","have","the","same","dims","[","batch-size",",","channels",",","height",",","width","]",",","2",")","p","(","z_","{","step","}","|z_","{","step+1","}",")",",","q","(","z_","{","step","}","|z_","{","step+1","}",",","data",")",",","q","(","z_","{","steps-1","}","|data",")","are","Gaussians","with","diagonal","covariance","matrix",",","3",")","p","(","z_","{","steps-1","}",")","is","a","standard","normal",".","Args",":","steps",":","The","number","of","steps\/hierarchchies","."]
docstr: If `data` is None, outputs the mean and stdd of the Gaussian
  prior p(z_{step}|z_{step+1}), where latent equals z_{step+1}.
  If `data` is provided, uses the posterior q(z_{step}|z_{step+1}, data).
  
  Args:
      latent: The latent z_{step+1} at the given step.
      step: The number of steps (minus 1). Here, 0 means one step.
      data: The input data array.
  Return:
      The parameters (mean and standard deviation)
      of the Gaussian prior or posterior.
docstr_tok: ["If","`","data","`","is","None",",","outputs","the","mean","and","stdd","of","the","Gaussian","prior","p","(","z_","{","step","}","|z_","{","step+1","}",")",",","where","latent","equals","z_","{","step+1","}",".","If","`","data","`","is","provided",",","uses","the","posterior","q","(","z_","{","step","}","|z_","{","step+1","}",",","data",")",".","Args",":","latent",":","The","latent","z_","{","step+1","}","at","the","given","step",".","step",":","The","number","of","steps","(","minus","1",")",".","Here",",","0","means","one","step",".","data",":","The","input","data","array",".","Return",":","The","parameters","(","mean","and","standard","deviation",")","of","the","Gaussian","prior","or","posterior","."]
code: def generate_fn(
      self,
      latent: np.ndarray,
      step: int,
      data: Optional[np.ndarray] = None,
  ) -> GaussianParams:
      """
      If `data` is None, outputs the mean and stdd of the Gaussian
      prior p(z_{step}|z_{step+1}), where latent equals z_{step+1}.
      If `data` is provided, uses the posterior q(z_{step}|z_{step+1}, data).
  
      Args:
          latent: The latent z_{step+1} at the given step.
          step: The number of steps (minus 1). Here, 0 means one step.
          data: The input data array.
      Return:
          The parameters (mean and standard deviation)
          of the Gaussian prior or posterior.
      """
  
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 3 for calling the BaseHLVModel obj's underlying member method code with example usage: obj.generate_fn(latent, step, data) without return types