docstr: Use this vocab class when you have a custom vocab as well as a
  custom embeddings file.
  
  This will inherit vocab class, so you will get predefined tokens with
  this one.
  
  IMPORTANT: To init your embedding, get your vectors from this class's
  object by calling `get_vectors` function
  
  Parameters
  ----------
  vocab_file : str
      Path of custom vocabulary
  embedding_file : str
      Path to custom embedding inititalization file
  data_dir : str
      Path to data directory if embedding file is not an absolute path.
      Default: None
docstr_tok: ["Use","this","vocab","class","when","you","have","a","custom","vocab","as","well","as","a","custom","embeddings","file",".","This","will","inherit","vocab","class",",","so","you","will","get","predefined","tokens","with","this","one",".","IMPORTANT",":","To","init","your","embedding",",","get","your","vectors","from","this","class's","object","by","calling","`","get_vectors","`","function","Parameters","--","--","--","--","--","vocab_file",":","str","Path","of","custom","vocabulary","embedding_file",":","str","Path","to","custom","embedding","inititalization","file","data_dir",":","str","Path","to","data","directory","if","embedding","file","is","not","an","absolute","path",".","Default",":","None"]
code: def __init__(
      self, vocab_file, embedding_file, data_dir=None, *args, **kwargs
  ):
      """Use this vocab class when you have a custom vocab as well as a
      custom embeddings file.
  
      This will inherit vocab class, so you will get predefined tokens with
      this one.
  
      IMPORTANT: To init your embedding, get your vectors from this class's
      object by calling `get_vectors` function
  
      Parameters
      ----------
      vocab_file : str
          Path of custom vocabulary
      embedding_file : str
          Path to custom embedding inititalization file
      data_dir : str
          Path to data directory if embedding file is not an absolute path.
          Default: None
      """
      super().__init__(vocab_file)
      self.type = "custom"
  
      if not os.path.isabs(embedding_file) and data_dir is not None:
          embedding_file = os.path.join(data_dir, embedding_file)
          embedding_file = get_absolute_path(embedding_file)
  
      if not PathManager.exists(embedding_file):
          raise RuntimeError(
              f"Embedding file path {embedding_file} doesn't exist"
          )
  
      embedding_vectors = torch.from_numpy(np.load(embedding_file))
  
      self.vectors = torch.FloatTensor(
          self.get_size(), len(embedding_vectors[0])
      )
  
      for i in range(0, 4):
          self.vectors[i] = torch.ones_like(self.vectors[i]) * 0.1 * i
  
      for i in range(4, self.get_size()):
          self.vectors[i] = embedding_vectors[i - 4]
  
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 CustomVocab object from inherited base classes: BaseVocab with example: obj = CustomVocab(vocab_file, embedding_file, data_dir)