class_docstr: Subclass BlenderBot2RagAgent to provide MemoryModel with appropriate inputs
  (specifically, memory vectors).
class_docstr_tok: ["Subclass","BlenderBot2RagAgent","to","provide","MemoryModel","with","appropriate","inputs","(","specifically",",","memory","vectors",")","."]
docstr: Tokenize the memories for use in read/write memory scoring.
  
  :param observation:
      observation with input text.
  
  :return observation:
      return observation with memory vec.
docstr_tok: ["Tokenize","the","memories","for","use","in","read\/write","memory","scoring",".",":","param","observation",":","observation","with","input","text",".",":","return","observation",":","return","observation","with","memory","vec","."]
code: def _set_memory_vec(self, observation: Message) -> Message:
      """
      Tokenize the memories for use in read/write memory scoring.
  
      :param observation:
          observation with input text.
  
      :return observation:
          return observation with memory vec.
      """
      mem_vecs = None
      method = KnowledgeAccessMethod(
          self.opt["knowledge_access_method"]
      )
      if method in [
          KnowledgeAccessMethod.ALL,
          KnowledgeAccessMethod.CLASSIFY,
          KnowledgeAccessMethod.MEMORY_ONLY,
      ]:
          memories = observation[self.opt["memory_key"]]
          if isinstance(memories, str):
              memories_splits = []
              if self.opt.get("memory_delimiter", None) is not None:
                  # extract memory separated by memory_delimiter up to the last split (which is the current session)
                  memories_splits = memories.split(
                      self.opt.get("memory_delimiter", "\n")
                  )[:-1]
              if len(memories_splits) == 0:
                  memories = [
                      t
                      for tt in memories.split(
                          self.opt.get("delimiter", "\n")
                      )
                      for t in tt.split("\n")
                  ]
              else:
                  memories = memories_splits
          assert isinstance(memories, list)
          if self.opt["memory_extractor_phrases"]:
              # extract from context
              memory_extractor_phrases = self.opt[
                  "memory_extractor_phrases"
              ].split(",")
              memories = [
                  m
                  for m in memories
                  if any(
                      [
                          mem_phrase in m
                          for mem_phrase in memory_extractor_phrases
                      ]
                  )
              ]
          model = self.model
          if isinstance(
              model, torch.nn.parallel.DistributedDataParallel
          ):
              model = self.model.module
          if memories:
              mem_vecs = [
                  model.tokenize_memory(mem) for mem in memories
              ]
  
      observation["memory_vec"] = mem_vecs
      return observation
  
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 3 for calling the MemoryRagAgent obj's underlying member method code with example usage: obj._set_memory_vec(observation) and returns: observation