class_docstr: Stochastic Variational Video Prediction Without Learned Prior.
class_docstr_tok: ["Stochastic","Variational","Video","Prediction","Without","Learned","Prior","."]
code: def body(self, features):
      hparams = self.hparams
      batch_size = common_layers.shape_list(features["inputs"])[0]
  
      # Swap time and batch axes.
      input_frames = common_video.swap_time_and_batch_axes(
          features["inputs"]
      )
      target_frames = common_video.swap_time_and_batch_axes(
          features["targets"]
      )
  
      # Get rewards if exist otherwise use zeros
      input_rewards = self.get_input_if_exists(
          features,
          "input_reward",
          batch_size,
          hparams.video_num_input_frames,
      )
      target_rewards = self.get_input_if_exists(
          features,
          "target_reward",
          batch_size,
          hparams.video_num_target_frames,
      )
  
      all_rewards = tf.concat([input_rewards, target_rewards], axis=0)
      all_frames = tf.concat([input_frames, target_frames], axis=0)
  
      # Get actions if exist otherwise use zeros
      visualization_kwargs = {}
      if hparams.action_type == "image":
          input_actions = common_video.swap_time_and_batch_axes(
              features["input_action"]
          )
          target_actions = common_video.swap_time_and_batch_axes(
              features["target_action"]
          )
          all_actions = tf.concat(
              [input_actions, target_actions], axis=0
          )
          time, _, h, w, c = all_frames.shape
          all_actions = tf.reshape(all_actions, (time, -1, h, w, c))
          if self.hparams.action_normalize:
              all_actions /= 255.0
          visualization_kwargs["actions"] = all_actions[:-1]
      else:
          input_actions = self.get_input_if_exists(
              features,
              "input_action",
              batch_size,
              hparams.video_num_input_frames,
          )
          target_actions = self.get_input_if_exists(
              features,
              "target_action",
              batch_size,
              hparams.video_num_target_frames,
          )
          all_actions = tf.concat(
              [input_actions, target_actions], axis=0
          )
  
      # Each image is being used twice, in latent tower and main tower.
      # This is to make sure we are using the *same* image for both, ...
      # ... given how TF queues work.
      # NOT sure if this is required at all. Doesn"t hurt though! :)
      all_frames = tf.identity(all_frames)
  
      retvals = self.construct_model(
          images=all_frames, actions=all_actions, rewards=all_rewards
      )
  
      # retrieve tensors returned by the model contructor
      gen_images = retvals["gen_images"]
      gen_rewards = retvals["fake_reward_prediction"]
      latent_means_pos = retvals["pred_mu_pos"]
      latent_logvars_pos = retvals["pred_logvar_pos"]
      latent_means_prior = retvals["pred_mu_prior"]
      latent_logvars_prior = retvals["pred_logvar_prior"]
  
      extra_loss = self.get_extra_loss(
          latent_means_pos=latent_means_pos,
          latent_logvars_pos=latent_logvars_pos,
          latent_means_prior=latent_means_prior,
          latent_logvars_prior=latent_logvars_prior,
      )
  
      # Visualize predictions in Tensorboard
      if self.is_training:
          self.visualize_predictions(
              all_frames[1:], gen_images, **visualization_kwargs
          )
  
      # Ignore the predictions from the input frames.
      # This is NOT the same as original paper/implementation.
      predictions = gen_images[hparams.video_num_input_frames - 1 :]
      reward_pred = gen_rewards[hparams.video_num_input_frames - 1 :]
      reward_pred = tf.squeeze(
          reward_pred, axis=2
      )  # Remove extra dimension.
  
      # Swap back time and batch axes.
      predictions = common_video.swap_time_and_batch_axes(predictions)
      reward_pred = common_video.swap_time_and_batch_axes(reward_pred)
  
      if self.is_training and hparams.internal_loss:
          # add the loss for input frames as well.
          extra_gts = all_frames[1 : hparams.video_num_input_frames]
          extra_gts = common_video.swap_time_and_batch_axes(extra_gts)
          extra_pds = gen_images[: hparams.video_num_input_frames - 1]
          extra_pds = common_video.swap_time_and_batch_axes(extra_pds)
          extra_raw_gts = features["inputs_raw"][:, 1:]
          recon_loss = self.get_extra_internal_loss(
              extra_raw_gts, extra_gts, extra_pds
          )
          extra_loss += recon_loss
  
      return_targets = predictions
      if hparams.reward_prediction:
          return_targets = {
              "targets": predictions,
              "target_reward": reward_pred,
          }
  
      return return_targets, extra_loss
  
file_path: tensor2tensor/tensor2tensor/models/video/emily.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import common_video
  from tensor2tensor.models.video import sv2p
  from tensor2tensor.models.video import sv2p_params
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 7 for calling the NextFrameEmily obj's underlying member method code with example usage: obj.body(features) and returns: return_targets,  extra_loss