class_docstr: Subclass LongRagAgent to provide MemoryRagAgent with appropriate generation_model
  (in particular MemoryLongRagModel that uses the ShiftInvariantEncoder)
class_docstr_tok: ["Subclass","LongRagAgent","to","provide","MemoryRagAgent","with","appropriate","generation_model","(","in","particular","MemoryLongRagModel","that","uses","the","ShiftInvariantEncoder",")"]
docstr: Build and return KnowledgeBotRagModel.
docstr_tok: ["Build","and","return","KnowledgeBotRagModel","."]
code: def build_model(
      self,
  ) -> Union[
      T5BlenderBot2RagModel, MemoryLongRagModel, BlenderBot2RagModel
  ]:
      """
      Build and return KnowledgeBotRagModel.
      """
      if self.generation_model == "t5":
          model = T5BlenderBot2RagModel(self.opt, self.dict)
      elif self.generation_model == "transformer_variant/generator":
          model = MemoryLongRagModel(self.opt, self.dict)
      else:
          model = BlenderBot2RagModel(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 typing import Optional, Union
  from parlai.core.message import Message
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from projects.blenderbot2.agents.sub_modules import KnowledgeAccessMethod
  from projects.blenderbot2.agents.modules import T5BlenderBot2RagModel, BlenderBot2RagModel, T5BlenderBot2FidModel, BlenderBot2FidModel, BlenderBot2FidModelMixin
  import torch
  from projects.blenderbot2.agents.blenderbot2 import BlenderBot2RagAgent
  from .long_rag import LongRagAgent, LongRagModel, LongFidAgent, LongFidModel
label_desc: Use image node_id 2 for calling the MemoryLongRagAgent obj's underlying member method code with example usage: obj.build_model() and returns: model