class_docstr: Builds and/or loads a dictionary.
  
  The dictionary provides access to the frequency of each token, functions to
  translate sentences from tokens to their vectors (list of ints, each int is the
  index of a token in the dictionary) and back from vectors to tokenized text.
class_docstr_tok: ["Builds","and\/or","loads","a","dictionary",".","The","dictionary","provides","access","to","the","frequency","of","each","token",",","functions","to","translate","sentences","from","tokens","to","their","vectors","(","list","of","ints",",","each","int","is","the","index","of","a","token","in","the","dictionary",")","and","back","from","vectors","to","tokenized","text","."]
docstr: Convert a string to a vector (list of ints).
  
  First runs a sentence tokenizer, then a word tokenizer.
  
  :param type vec_type:
      The type of the returned vector if the input is a string. Suggested
      ``list``, ``tuple``, ``set``, or ``np.ndarray``.
code: def txt2vec(self, text: str, vec_type=list):
      """
      Convert a string to a vector (list of ints).
  
      First runs a sentence tokenizer, then a word tokenizer.
  
      :param type vec_type:
          The type of the returned vector if the input is a string. Suggested
          ``list``, ``tuple``, ``set``, or ``np.ndarray``.
      """
      assert isinstance(
          text, str
      ), f"Input to txt2vec must be string, not {type(text)}"
  
      itr = (self._word_lookup(token) for token in self.tokenize(text))
      if vec_type == list or vec_type == tuple or vec_type == set:
          res = vec_type(itr)
      elif vec_type == np.ndarray:
          res = np.fromiter(itr, np.int)
      else:
          raise RuntimeError(
              "Type {} not supported by dict".format(vec_type)
          )
      return res
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.build_data import modelzoo_path
  from parlai.utils.bpe import bpe_factory, BPEHelper
  from .agents import Agent
  from .build_data import make_dir
  from collections import defaultdict
  import copy
  import numpy
  import os
  import json
  import re
  import parlai.utils.logging
  from parlai.utils.io import PathManager
  from typing import List
  import enum
label_desc: Use image node_id 31 for calling the DictionaryAgent obj's underlying member method code with example usage: obj.txt2vec(text, vec_type) and returns: res