class_docstr: BART Agent.
  
  Relies on the BART model implemented in fairseq.
  
  If you have a fine-tuned BART model from fairseq, you can specify the
  `--init-fairseq-model` arg, which will convert your fine-tuned model
  to a ParlAI model.
class_docstr_tok: ["BART","Agent",".","Relies","on","the","BART","model","implemented","in","fairseq",".","If","you","have","a","fine-tuned","BART","model","from","fairseq",",","you","can","specify","the","`","--","init-fairseq-model","`","arg",",","which","will","convert","your","fine-tuned","model","to","a","ParlAI","model","."]
docstr: Override to prepend start token and append end token.
docstr_tok: ["Override","to","prepend","start","token","and","append","end","token","."]
code: def _set_text_vec(
      self, obs: Message, history: History, truncate: Optional[int]
  ) -> Message:
      """
      Override to prepend start token and append end token.
      """
      obs = super()._set_text_vec(obs, history, truncate)
      if "text" not in obs or "text_vec" not in obs:
          return obs
      vec = obs["text_vec"]
  
      # add start/end tokens
      if "added_start_end_tokens" not in obs:
          if truncate is not None:
              vec = torch.LongTensor(  # type: ignore
                  self._check_truncate(
                      obs["text_vec"], truncate - 2, True
                  )
              )
          obs.force_set(
              "text_vec",
              self._add_start_end_tokens(
                  vec, add_start=True, add_end=True
              ),
          )
          obs["added_start_end_tokens"] = True
  
      return obs
  
imports: import os
  import torch
  from typing import Optional, Dict, Any
  from parlai.agents.bart.convert_fairseq_to_parlai import ConversionScript
  from parlai.agents.bart.modules import BartModel
  from parlai.agents.transformer.transformer import TransformerGeneratorAgent
  from parlai.core.agents import compare_init_model_opts
  from parlai.core.message import Message
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.torch_agent import History
  from parlai.utils.typing import TShared
  from parlai.utils.io import PathManager
  from parlai.zoo.bart.build import download, CONVERSION_ARGS, BART_ARGS
label_desc: Use image node_id 7 for calling the BartAgent obj's underlying member method code with example usage: obj._set_text_vec(obs, history, truncate) and returns: obs, obs