code: def get_extra_loss(self, latent_means=None, latent_stds=None,
                       true_frames=None, gen_frames=None):
      
      if not self.is_training:
        return 0.0
  
      vae_loss, d_vae_loss, d_gan_loss = 0.0, 0.0, 0.0
      # Use sv2p's KL divergence computation.
      if self.hparams.use_vae:
        vae_loss = super(NextFrameSavpBase, self).get_extra_loss(
            latent_means=latent_means, latent_stds=latent_stds)
  
      if self.hparams.use_gan:
        # Strip out the first context_frames for the true_frames
        # Strip out the first context_frames - 1 for the gen_frames
        context_frames = self.hparams.video_num_input_frames
        true_frames = tf.stack(
            tf.unstack(true_frames, axis=0)[context_frames:])
  
        # discriminator for VAE.
        if self.hparams.use_vae:
          gen_enc_frames = tf.stack(
              tf.unstack(gen_frames, axis=0)[context_frames-1:])
          d_vae_loss = self.get_gan_loss(true_frames, gen_enc_frames, name="vae")
  
        # discriminator for GAN.
        gen_prior_frames = tf.stack(
            tf.unstack(self.gen_prior_video, axis=0)[context_frames-1:])
        d_gan_loss = self.get_gan_loss(true_frames, gen_prior_frames, name="gan")
  
      return (
          vae_loss + self.hparams.gan_loss_multiplier * d_gan_loss +
          self.hparams.gan_vae_loss_multiplier * d_vae_loss)
docs: Gets extra loss from VAE and GAN.