def glow_encoder(self, frame, condition=False, cond_latents=None, init=False):
    """Glow network that encodes frame to a hierarchy of latents.

    Args:
      frame: 5-D Tensor of shape (batch_size, 1, height, width, channels).
      condition: Whether or not to condition on cond_latents.
      cond_latents: optional, list of tensors with length equal to
                    hparams.n_levels - 1. If provided, the latent at level l is
                    conditioned on the cond_latent at level l.
      init: Whether the given batch is an "init" batch or a "train" batch.
    Returns:
      objective: log-likelihood of the frame per the model.
      z_top: top-level latent.
      z_levels: a list of tensors with latents at all levels.
    """
    frame = self.squeeze_video(frame, init=init)
    frame = self.preprocess(frame)
    frame, objective = glow_ops.uniform_binning_correction(frame)

    glow_vals = glow_ops.encoder_decoder(
        "codec", frame, self.hparams, eps=None, reverse=False,
        cond_latents=cond_latents, states=self.level_states,
        condition=condition)
    z_top, encoder_objective, self.eps, z_levels, self.level_states = glow_vals
    objective += encoder_objective
    return objective, z_top, z_levels
Glow network that encodes frame to a hierarchy of latents.

    Args:
      frame: 5-D Tensor of shape (batch_size, 1, height, width, channels).
      condition: Whether or not to condition on cond_latents.
      cond_latents: optional, list of tensors with length equal to
                    hparams.n_levels - 1. If provided, the latent at level l is
                    conditioned on the cond_latent at level l.
      init: Whether the given batch is an "init" batch or a "train" batch.
    Returns:
      objective: log-likelihood of the frame per the model.
      z_top: top-level latent.
      z_levels: a list of tensors with latents at all levels.
    
tensor2tensor/models/video/next_frame_glow.py