class_docstr: Fusion in Decoder Agent.
  
  Fusion in Decoder is very similar to RAG; each requires a retrieval and subsequent
  generation step.
  
  The difference is that FiD will encode all documents in parallel in encoder,
  concatenate, and feed as one giant encoding to Decoder.
  
  This forces the Decoder to attend over the several documents directly,
  rather than marginalizing later.
  
  As such, FidAgent is a natural extension of the RagAgent. I've extracted out to its
  own agent for ease of use.
class_docstr_tok: ["Fusion","in","Decoder","Agent",".","Fusion","in","Decoder","is","very","similar","to","RAG",";","each","requires","a","retrieval","and","subsequent","generation","step",".","The","difference","is","that","FiD","will","encode","all","documents","in","parallel","in","encoder",",","concatenate",",","and","feed","as","one","giant","encoding","to","Decoder",".","This","forces","the","Decoder","to","attend","over","the","several","documents","directly",",","rather","than","marginalizing","later",".","As","such",",","FidAgent","is","a","natural","extension","of","the","RagAgent",".","I","'ve","extracted","out","to","its","own","agent","for","ease","of","use","."]
code: def build_model(self) -> FidModel:
      if self.generation_model == "t5":
          model = T5FidModel(self.opt, self.dict)
      else:
          model = FidModel(self.opt, self.dict)
      if self.opt["embedding_type"] != "random":
          self._copy_embeddings(
              model.encoder.embeddings.weight,
              self.opt["embedding_type"],
          )
      return model
  
imports: from abc import abstractmethod
  from copy import deepcopy
  import torch
  import random
  from typing import Tuple, Union, Optional, List, Dict, Any
  from parlai.core.dict import DictionaryAgent
  from parlai.core.opt import Opt
  from parlai.core.message import Message
  from parlai.agents.transformer.transformer import TransformerGeneratorModel
  from parlai.agents.rag.args import RetrieverType
  from parlai.agents.rag.modules import RagModel, Document, T5RagModel
  from parlai.agents.rag.rag import RagAgent
  from parlai.agents.rag.model_types import RagToken, get_forced_decoder_inputs, fix_incremental_state
  from parlai.utils.typing import TShared
  import parlai.utils.logging
  from parlai.tasks.wizard_of_internet import constants
label_desc: Use image node_id 3 for calling the FidAgent obj's underlying member method code with example usage: obj.build_model() and returns: model