class_docstr: Base class for next_frame models.
  
  This is the base class for the models that given the previous frames
  can predict the next frame. They may also support reward prediction
  and action condition prediction which enables them to be run as
  a world model in model-based RL pipeline.
  
  The API supports both recurrent and stacked frames models. Please look
  at the documents for next_frame function for the API.
  
  If you are implementing a next frame prediction model consider
  following the API presented in this class. But if the API
  is too limiting for your models, feel free to override lower level
  functions and/or inheret from T2TModel directly.
class_docstr_tok: ["Base","class","for","next_frame","models",".","This","is","the","base","class","for","the","models","that","given","the","previous","frames","can","predict","the","next","frame",".","They","may","also","support","reward","prediction","and","action","condition","prediction","which","enables","them","to","be","run","as","a","world","model","in","model-based","RL","pipeline",".","The","API","supports","both","recurrent","and","stacked","frames","models",".","Please","look","at","the","documents","for","next_frame","function","for","the","API",".","If","you","are","implementing","a","next","frame","prediction","model","consider","following","the","API","presented","in","this","class",".","But","if","the","API","is","too","limiting","for","your","models",",","feel","free","to","override","lower","level","functions","and\/or","inheret","from","T2TModel","directly","."]
docstr: Hacky code the get the loss on predicted frames from input frames.
  
     Recurrent models consume the frames one-by-one. Therefore
     if there is more than one input frame they also get predicted.
     T2T only calculates loss on the predicted target frames which
     means the loss is not being applied on the predicted input frames.
     This code is to fix this issue. Since the model is not aware of the
     modality it has to match the pre-porocessing happening in bottom
     function and therefore this becomes a very hacky code. This code
     should match the bottom and top and loss of modalities otherwise
     it will calculate the wrong loss.
  
  Args:
    extra_raw_gts: extra raw ground truth frames.
    extra_gts: extra normalized ground truth frames.
    extra_pds: extra predicted frames.
  
  Returns:
    Additional reconstruction loss.
  
  Raises:
    ValueError: in case of unknown loss transformation.
docstr_tok: ["Hacky","code","the","get","the","loss","on","predicted","frames","from","input","frames",".","Recurrent","models","consume","the","frames","one-by-one",".","Therefore","if","there","is","more","than","one","input","frame","they","also","get","predicted",".","T2T","only","calculates","loss","on","the","predicted","target","frames","which","means","the","loss","is","not","being","applied","on","the","predicted","input","frames",".","This","code","is","to","fix","this","issue",".","Since","the","model","is","not","aware","of","the","modality","it","has","to","match","the","pre-porocessing","happening","in","bottom","function","and","therefore","this","becomes","a","very","hacky","code",".","This","code","should","match","the","bottom","and","top","and","loss","of","modalities","otherwise","it","will","calculate","the","wrong","loss",".","Args",":","extra_raw_gts",":","extra","raw","ground","truth","frames",".","extra_gts",":","extra","normalized","ground","truth","frames",".","extra_pds",":","extra","predicted","frames",".","Returns",":","Additional","reconstruction","loss",".","Raises",":","ValueError",":","in","case","of","unknown","loss","transformation","."]
code: def get_extra_internal_loss(
      self, extra_raw_gts, extra_gts, extra_pds
  ):
      """Hacky code the get the loss on predicted frames from input frames.
  
         Recurrent models consume the frames one-by-one. Therefore
         if there is more than one input frame they also get predicted.
         T2T only calculates loss on the predicted target frames which
         means the loss is not being applied on the predicted input frames.
         This code is to fix this issue. Since the model is not aware of the
         modality it has to match the pre-porocessing happening in bottom
         function and therefore this becomes a very hacky code. This code
         should match the bottom and top and loss of modalities otherwise
         it will calculate the wrong loss.
  
      Args:
        extra_raw_gts: extra raw ground truth frames.
        extra_gts: extra normalized ground truth frames.
        extra_pds: extra predicted frames.
  
      Returns:
        Additional reconstruction loss.
  
      Raises:
        ValueError: in case of unknown loss transformation.
      """
      # TODO(trandustin): This logic should be moved elsewhere.
      if (
          self.hparams.loss.get("targets")
          == modalities.video_l2_raw_loss
      ):
          recon_loss = tf.losses.mean_squared_error(
              extra_gts, extra_pds
          )
      elif "targets" not in self.hparams.loss:
          shape = common_layers.shape_list(extra_pds)
          updated_shape = shape[:-1] + [3, 256]
          extra_pds = tf.reshape(extra_pds, updated_shape)
          # Merge time and batch
          logits = tf.reshape(extra_pds, [-1] + updated_shape[2:])
          targets = extra_raw_gts
          targets_shape = common_layers.shape_list(targets)
          targets = tf.reshape(targets, [-1] + targets_shape[2:])
          targets_weights_fn = self.hparams.weights_fn.get(
              "targets",
              modalities.get_weights_fn(self._target_modality),
          )
          numerator, denominator = common_layers.padded_cross_entropy(
              logits,
              targets,
              self.hparams.label_smoothing,
              cutoff=getattr(
                  self.hparams, "video_modality_loss_cutoff", 0.01
              ),
              weights_fn=targets_weights_fn,
          )
          recon_loss = numerator / denominator
      else:
          raise ValueError(
              "internal loss only supports specific hparams.loss."
          )
      tf.summary.scalar("recon_extra", recon_loss)
      return recon_loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import six
  from tensor2tensor.layers import common_hparams
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import common_video
  from tensor2tensor.layers import discretization
  from tensor2tensor.layers import modalities
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
label_desc: Use image node_id 16 for calling the NextFrameBase obj's underlying member method code with example usage: obj.get_extra_internal_loss(extra_raw_gts, extra_gts, extra_pds) and returns: recon_loss