docstr: Set the 'text_vec' field in the observation.
  
  Overridden to include both local utterance (text_vec) and full history
  (context_vec)
docstr_tok: ["Set","the","'text_vec","'","field","in","the","observation",".","Overridden","to","include","both","local","utterance","(","text_vec",")","and","full","history","(","context_vec",")"]
code: def _set_text_vec(self, obs, history, truncate):
      """
      Set the 'text_vec' field in the observation.
  
      Overridden to include both local utterance (text_vec) and full history
      (context_vec)
      """
      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
          history_string = history.get_history_str()
          # when text not exist, we get text_vec from history string
          # history could be none if it is an image task and 'text'
          # filed is be empty. We don't want this
          if history_string is None:
              return obs
          obs["full_text"] = history_string
          if history_string:
              history_vec = history.get_history_vec_list()
              obs["text_vec"] = history_vec[-1]
              obs["full_text_vec"] = history.get_history_vec()
              obs["context_vec"] = history_vec
  
      # check truncation
      if obs.get("text_vec") is not None:
          truncated_vec = self._check_truncate(
              obs["text_vec"], truncate, True
          )
          obs.force_set("text_vec", torch.LongTensor(truncated_vec))
      return obs
  
file_path: ParlAI/parlai/agents/hred/hred.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import torch
  from parlai.agents.seq2seq.modules import opt_to_kwargs
  from parlai.core.torch_generator_agent import TorchGeneratorAgent
  from .modules import HredModel
label_desc: Use image node_id 6 for calling the HredAgent obj's underlying member method code with example usage: obj._set_text_vec(obs, history, truncate) and returns: obs, obs, obs