class_docstr: Memory Network agent.
  
  Tips:
  - time features are necessary when memory order matters
  - multiple hops allow multiple steps of reasoning, but also seem to make it
      easier to learn to read the memories if you have at least two hops
  - 'adam' seems to work very poorly compared to 'sgd' for hogwild training
class_docstr_tok: ["Memory","Network","agent",".","Tips",":","-","time","features","are","necessary","when","memory","order","matters","-","multiple","hops","allow","multiple","steps","of","reasoning",",","but","also","seem","to","make","it","easier","to","learn","to","read","the","memories","if","you","have","at","least","two","hops","-","'adam","'","seems","to","work","very","poorly","compared","to","'sgd","'","for","hogwild","training"]
docstr: Override from Torch Agent so that we can use memories.
docstr_tok: ["Override","from","Torch","Agent","so","that","we","can","use","memories","."]
code: def _set_text_vec(self, obs, history, truncate):
      """
      Override from Torch Agent so that we can use memories.
      """
      if "text" not in obs:
          return obs
  
      if "text_vec" not in obs:
          # text vec is not precomputed, so we set it using the history
          obs["full_text"] = history.get_history_str()
          history_vecs = history.get_history_vec_list()
          if len(history_vecs) > 0:
              obs["memory_vecs"] = history_vecs[:-1]
              obs["text_vec"] = history_vecs[-1]
          else:
              obs["memory_vecs"] = []
              obs["text_vec"] = []
  
      # check truncation
      if "text_vec" in obs:
          truncated_vec = self._check_truncate(
              obs["text_vec"], truncate, True
          )
          obs.force_set("text_vec", torch.LongTensor(truncated_vec))
  
      if "memory_vecs" in obs:
          obs.force_set(
              "memory_vecs",
              [
                  torch.LongTensor(
                      self._check_truncate(m, truncate, True)
                  )
                  for m in obs["memory_vecs"]
              ],
          )
  
      return obs
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from functools import lru_cache
  import torch
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from .modules import MemNN, opt_to_kwargs
label_desc: Use image node_id 11 for calling the MemnnAgent obj's underlying member method code with example usage: obj._set_text_vec(obs, history, truncate) and returns: obs, obs