code: def temporal_latent_to_dist(name, x, hparams, output_channels=None):
      """Network that maps a time-indexed list of 3-D latents to a gaussian.
  
      Args:
        name: variable scope.
        x: List of 4-D Tensors indexed by time, (NHWC)
        hparams: tf.contrib.training.Hparams.
        output_channels: int, Number of channels of the output gaussian mean.
      Returns:
        dist: tfp.distributions.Normal
      """
      _, _, width, _, res_channels = common_layers.shape_list(x)
      if output_channels is None:
          output_channels = res_channels
      dilation_rates = get_dilation_rates(hparams, width)
      with tf.variable_scope(name, reuse=tf.AUTO_REUSE):
          h = x
          for i in range(hparams.latent_encoder_depth):
              if hparams.latent_apply_dilations:
                  h2 = dilated_conv_stack(
                      "dil_latent_3d_res_%d" % i,
                      h,
                      mid_channels=hparams.latent_encoder_width,
                      output_channels=res_channels,
                      dilation_rates=dilation_rates,
                      activation=hparams.latent_activation,
                      dropout=hparams.latent_dropout,
                  )
              else:
                  h2 = conv_stack(
                      "latent_3d_res_%d" % i,
                      h,
                      mid_channels=hparams.latent_encoder_width,
                      output_channels=res_channels,
                      activation=hparams.latent_activation,
                      dropout=hparams.latent_dropout,
                  )
              h += h2
  
          # take last activation that should capture all context since padding is
          # on left.
          h = h[:, -1, :, :, :]
          h = conv(
              "res_final",
              h,
              apply_actnorm=False,
              conv_init="zeros",
              output_channels=2 * output_channels,
              filter_size=[1, 1],
          )
          mean, log_scale = h[:, :, :, 0::2], h[:, :, :, 1::2]
      return tfp.distributions.Normal(mean, tf.exp(log_scale))
  
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 27 for calling a global function with example usage: temporal_latent_to_dist(name, x, hparams, output_channels) and returns: tfp