code: def __init__(self, *args, **params):
      vocab_type = params.get("type", "pretrained")
      # Stores final parameters extracted from vocab_params
  
      if vocab_type == "random":
          if params["vocab_file"] is None:
              raise ValueError("No vocab path passed for vocab")
  
          self.vocab = BaseVocab(*args, **params)
  
      elif vocab_type == "custom":
          if (
              params["vocab_file"] is None
              or params["embedding_file"] is None
          ):
              raise ValueError(
                  "No vocab path or embedding_file passed for vocab"
              )
          self.vocab = CustomVocab(*args, **params)
  
      elif vocab_type == "pretrained":
          self.vocab = PretrainedVocab(*args, **params)
  
      elif vocab_type == "intersected":
          if (
              params["vocab_file"] is None
              or params["embedding_name"] is None
          ):
              raise ValueError(
                  "No vocab path or embedding_name passed for vocab"
              )
  
          self.vocab = IntersectedVocab(*args, **params)
  
      elif vocab_type == "extracted":
          if (
              params["base_path"] is None
              or params["embedding_dim"] is None
          ):
              raise ValueError(
                  "No base_path or embedding_dim passed for vocab"
              )
          self.vocab = ExtractedVocab(*args, **params)
  
      elif vocab_type == "model":
          if params["name"] is None or params["model_file"] is None:
              raise ValueError("No name or model_file passed for vocab")
          if params["name"] == "fasttext":
              self.vocab = ModelVocab(*args, **params)
      else:
          raise ValueError("Unknown vocab type: %s" % vocab_type)
  
      self._dir_representation = dir(self)
  
imports: import logging
  import os
  from collections import defaultdict
  import numpy
  import torch
  from mmf.utils.configuration import get_mmf_cache_dir
  from mmf.utils.distributed import is_main, synchronize
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_absolute_path
  from torchtext import vocab
label_desc: Use image node_id 1 to create a new Vocab object  with example: obj = Vocab()