docstr: Overriding decoder_output method to use classifier heads to modify the generator
  logprobs. This modification allows model to incorporate attribute information
  from classifier while selecting the next tokens.
  
  Notice that the output method of a RagModel is an identity mapping. One need to override the RagModel.decoder_output instead
  
  Args:
      latent (torch.Tensor): decoder outputs
      encoder_states (tuple[Any, ...]): encoder states after the final decoder layer of seq2seq_decoder
  
  Returns:
      Modified logprobs.
docstr_tok: ["Overriding","decoder_output","method","to","use","classifier","heads","to","modify","the","generator","logprobs",".","This","modification","allows","model","to","incorporate","attribute","information","from","classifier","while","selecting","the","next","tokens",".","Notice","that","the","output","method","of","a","RagModel","is","an","identity","mapping",".","One","need","to","override","the","RagModel.decoder_output","instead","Args",":","latent","(","torch.Tensor",")",":","decoder","outputs","encoder_states","(","tuple","[","Any",",","...","]",")",":","encoder","states","after","the","final","decoder","layer","of","seq2seq_decoder","Returns",":","Modified","logprobs","."]
code: def decoder_output(
      self,
      latent: torch.Tensor,
      encoder_states: Optional[Tuple[Any, ...]] = None,
  ):
      """
      Overriding decoder_output method to use classifier heads to modify the generator
      logprobs. This modification allows model to incorporate attribute information
      from classifier while selecting the next tokens.
  
      Notice that the output method of a RagModel is an identity mapping. One need to override the RagModel.decoder_output instead
  
      Args:
          latent (torch.Tensor): decoder outputs
          encoder_states (tuple[Any, ...]): encoder states after the final decoder layer of seq2seq_decoder
  
      Returns:
          Modified logprobs.
      """
      classifier_outputs = F.logsigmoid(
          self.classifier_output(latent, encoder_states=encoder_states)
      )
      log_predictor_scores = F.log_softmax(
          self.generator_output(latent), dim=-1
      )
  
      if self.use_one_plus_gamma_variant:
          scores = (
              log_predictor_scores
              + self.infer_gamma * classifier_outputs
          )
      else:
          scores = (
              2.0
              * (1.0 - self.infer_mixing_weights)
              * log_predictor_scores
              + 2.0 * (self.infer_mixing_weights) * classifier_outputs
          )
      return F.log_softmax(scores, dim=-1)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from typing import Optional, Any, Dict, Tuple, Union, List
  from abc import abstractmethod
  from parlai.agents.transformer.modules import TransformerDecoderLayer
  from parlai.agents.fid.fid import FidAgent, FidModel
  from parlai.core.message import Message
  from parlai.core.metrics import AverageMetric
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.torch_generator_agent import PPLMetric
  from parlai.core.torch_agent import Batch, DictionaryAgent
  import parlai.utils.logging
  from projects.blenderbot2.agents.blenderbot2 import BlenderBot2FidAgent, BlenderBot2FidModel, T5BlenderBot2FidModel
  from parlai.agents.fid.fid import WizIntGoldDocRetrieverFiDAgent
  import parlai.agents.transformer.modules.ffn
  from parlai.agents.transformer.modules import LAYER_NORM_EPS
label_desc: Use image node_id 4 for calling the DirectorFidModelMixin obj's underlying member method code with example usage: obj.decoder_output(latent, encoder_states) and returns: F