code: def level_cond_prior(prior_dist, z, latent, hparams, state):
      """Returns a conditional prior for each level.
  
      Args:
        prior_dist: Distribution conditioned on the previous levels.
        z: Tensor, output of the previous levels.
        latent: Tensor or a list of tensors to condition the latent_distribution.
        hparams: next_frame_glow hparams.
        state: Current LSTM state. Used only if hparams.latent_dist_encoder is
               a lstm.
      Raises:
        ValueError: If hparams.latent_dist_encoder is "pointwise" and if the shape
                    of latent is different from z.
      """
      latent_dist_encoder = hparams.get("latent_dist_encoder", None)
      latent_skip = hparams.get("latent_skip", False)
      if latent_dist_encoder == "pointwise":
          last_latent = latent
          merge_std = hparams.level_scale
          latent_shape = common_layers.shape_list(latent)
          z_shape = common_layers.shape_list(z)
          if latent_shape != z_shape:
              raise ValueError(
                  "Expected latent_shape to be %s, got %s"
                  % (latent_shape, z_shape)
              )
          latent_dist = scale_gaussian_prior(
              "latent_prior", latent, logscale_factor=3.0
          )
          cond_dist = merge_level_and_latent_dist(
              prior_dist, latent_dist, merge_std=merge_std
          )
  
      elif latent_dist_encoder == "conv_net":
          output_channels = common_layers.shape_list(z)[-1]
          last_latent = latent[-1]
          latent_stack = tf.concat([prior_dist.loc] + latent, axis=-1)
          latent_stack = noise_op(latent_stack, hparams)
          cond_dist = latent_to_dist(
              "latent_stack",
              latent_stack,
              hparams=hparams,
              output_channels=output_channels,
          )
  
      elif latent_dist_encoder == "conv3d_net":
          last_latent = latent[-1]
          output_channels = common_layers.shape_list(last_latent)[-1]
          num_steps = len(latent)
  
          # Stack across time.
          cond_latents = tf.stack(latent, axis=1)
  
          # Concat latents from previous levels across channels.
          prev_latents = tf.tile(
              tf.expand_dims(prior_dist.loc, axis=1),
              [1, num_steps, 1, 1, 1],
          )
          cond_latents = tf.concat(
              (cond_latents, prev_latents), axis=-1
          )
          cond_latents = noise_op(cond_latents, hparams)
          cond_dist = temporal_latent_to_dist(
              "latent_stack",
              cond_latents,
              hparams,
              output_channels=output_channels,
          )
  
      elif latent_dist_encoder == "conv_lstm":
          last_latent = latent
          output_channels = common_layers.shape_list(z)[-1]
          latent_stack = tf.concat((prior_dist.loc, latent), axis=-1)
          latent_stack = noise_op(latent_stack, hparams)
          _, state = common_video.conv_lstm_2d(
              latent_stack,
              state,
              hparams.latent_encoder_width,
              kernel_size=3,
              name="conv_lstm",
          )
  
          cond_dist = single_conv_dist(
              "state_to_dist", state.h, output_channels=output_channels
          )
      if latent_skip:
          new_mean = cond_dist.loc + last_latent
          cond_dist = tfp.distributions.Normal(
              new_mean, cond_dist.scale
          )
      return cond_dist.loc, cond_dist.scale, state
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import numpy
  import scipy
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import common_video
  from tensor2tensor.utils import contrib
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  import tensorflow_probability
label_desc: Use image node_id 32 for calling a global function with example usage: level_cond_prior(prior_dist, z, latent, hparams, state) and returns: cond_dist,  cond_dist,  state