class_docstr: Old SV2P code. Only for legacy reasons.
class_docstr_tok: ["Old","SV2P","code",".","Only","for","legacy","reasons","."]
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 actions if exist otherwise use zeros
      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,
      )
  
      # 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_actions = tf.concat([input_actions, target_actions], axis=0)
      all_rewards = tf.concat([input_rewards, target_rewards], axis=0)
      all_frames = tf.concat([input_frames, target_frames], 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)
  
      (
          gen_images,
          gen_rewards,
          latent_means,
          latent_stds,
      ) = self.construct_model(
          images=all_frames,
          actions=all_actions,
          rewards=all_rewards,
      )
  
      extra_loss = self.get_extra_loss(
          latent_means=latent_means,
          latent_stds=latent_stds,
          true_frames=all_frames,
          gen_frames=gen_images,
      )
  
      # Visualize predictions in Tensorboard
      if self.is_training:
          self.visualize_predictions(all_frames[1:], gen_images)
  
      # 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
  
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.layers import discretization
  from tensor2tensor.models.video import base
  from tensor2tensor.models.video import base_vae
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 5 for calling the NextFrameSv2pLegacy obj's underlying member method code with example usage: obj.body(features) and returns: return_targets,  extra_loss