class_docstr: Stochastic Adversarial Video Prediction for RL pipeline.
code: def next_frame(
      self,
      frames,
      actions,
      rewards,
      target_frame,
      internal_states,
      video_features,
  ):
      del target_frame
  
      if not self.hparams.use_vae or self.hparams.use_gan:
          raise NotImplementedError("Only supporting VAE for now.")
  
      if self.has_pred_actions or self.has_values:
          raise NotImplementedError(
              "Parameter sharing with policy not supported."
          )
  
      image, action, reward = frames[0], actions[0], rewards[0]
      latent_dims = self.hparams.z_dim
      batch_size = common_layers.shape_list(image)[0]
  
      if internal_states is None:
          # Initialize LSTM State
          frame_index = 0
          lstm_state = [None] * 7
          cond_latent_state, prior_latent_state = None, None
          gen_prior_video = []
      else:
          (
              frame_index,
              lstm_state,
              cond_latent_state,
              prior_latent_state,
              gen_prior_video,
          ) = internal_states
  
      z_mu, log_sigma_sq = video_features
      z_mu, log_sigma_sq = z_mu[frame_index], log_sigma_sq[frame_index]
  
      # Sample latents using a gaussian centered at conditional mu and std.
      latent = common_video.get_gaussian_tensor(z_mu, log_sigma_sq)
  
      # Sample prior latents from isotropic normal distribution.
      prior_latent = tf.random_normal(
          tf.shape(latent), dtype=tf.float32
      )
  
      # # LSTM that encodes correlations between conditional latents.
      # # Pg 22 in https://arxiv.org/pdf/1804.01523.pdf
      enc_cond_latent, cond_latent_state = common_video.basic_lstm(
          latent, cond_latent_state, latent_dims, name="cond_latent"
      )
  
      # LSTM that encodes correlations between prior latents.
      enc_prior_latent, prior_latent_state = common_video.basic_lstm(
          prior_latent,
          prior_latent_state,
          latent_dims,
          name="prior_latent",
      )
  
      all_latents = tf.concat(
          [enc_cond_latent, enc_prior_latent], axis=0
      )
      all_image = tf.concat([image, image], 0)
      all_action = (
          tf.concat([action, action], 0) if self.has_actions else None
      )
  
      all_pred_images, lstm_state = self.construct_predictive_tower(
          all_image,
          None,
          all_action,
          lstm_state,
          all_latents,
          concat_latent=True,
      )
  
      cond_pred_images, prior_pred_images = (
          all_pred_images[:batch_size],
          all_pred_images[batch_size:],
      )
  
      if self.is_training and self.hparams.use_vae:
          pred_image = cond_pred_images
      else:
          pred_image = prior_pred_images
  
      gen_prior_video.append(prior_pred_images)
      internal_states = (
          frame_index + 1,
          lstm_state,
          cond_latent_state,
          prior_latent_state,
          gen_prior_video,
      )
  
      if not self.has_rewards:
          return pred_image, None, 0.0, internal_states
  
      pred_reward = self.reward_prediction(
          pred_image, action, reward, latent
      )
      return pred_image, pred_reward, None, None, 0.0, internal_states
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numbers
  import numpy
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import common_video
  from tensor2tensor.models.video import savp_params
  from tensor2tensor.models.video import sv2p
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import update_ops_hook
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  import tensorflow_gan
label_desc: Use image node_id 3 for calling the NextFrameSavpRl obj's underlying member method code with example usage: obj.next_frame(frames, actions, rewards, target_frame, internal_states, video_features) and returns: pred_image,  pred_reward,  None,  None,  int,  internal_states, pred_image,  None,  int,  internal_states