code: def word2idx(self, w):
      if w in self.word2idx_dict:
          return self.word2idx_dict[w]
      elif self.UNK_INDEX is not None:
          return self.UNK_INDEX
      else:
          raise ValueError(
              "word %s not in dictionary \
                               (while dictionary does not contain <unk>)"
              % w
          )
  
imports: import os
  import re
  from collections import Counter
  from itertools import chain
  import torch
  from mmf.common.registry import registry
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_absolute_path
label_desc: Use image node_id 8 for calling the VocabDict obj's underlying member method code with example usage: obj.word2idx(w) and returns: self, self