code: def init_vocab(self, data):
      def from_model(model_filename):
          """Try loading vocab from charLM model file."""
          state_dict = torch.load(
              model_filename, lambda storage, loc: storage
          )
          if "vocab" in state_dict:
              return state_dict["vocab"]
          if "model" in state_dict and "vocab" in state_dict["model"]:
              return state_dict["model"]["vocab"]
          raise ValueError(
              "Cannot find vocab in charLM model file %s"
              % model_filename
          )
  
      if self.eval:
          raise AssertionError("Vocab must exist for evaluation.")
      if self.args["charlm"]:
          charvocab = CharVocab.load_state_dict(
              from_model(self.args["charlm_forward_file"])
          )
      else:
          charvocab = CharVocab(data, self.args["shorthand"])
      wordvocab = self.pretrain.vocab
      tag_data = [[(x[1],) for x in sentence] for sentence in data]
      tagvocab = CompositeVocab(
          tag_data, self.args["shorthand"], idx=0, sep=None
      )
      ignore = None
      if self.args["emb_finetune_known_only"]:
          if self.args["lowercase"]:
              ignore = set(
                  [
                      w[0]
                      for sent in data
                      for w in sent
                      if w[0] in wordvocab or w[0].lower() in wordvocab
                  ]
              )
          else:
              ignore = set(
                  [
                      w[0]
                      for sent in data
                      for w in sent
                      if w[0] in wordvocab
                  ]
              )
          logger.debug(
              "Ignoring %d in the delta vocab as they did not appear in the original embedding",
              len(ignore),
          )
      deltavocab = WordVocab(
          data,
          self.args["shorthand"],
          cutoff=1,
          lower=self.args["lowercase"],
          ignore=ignore,
      )
      logger.debug("Creating delta vocab of size %s", len(deltavocab))
      vocab = MultiVocab(
          {
              "char": charvocab,
              "word": wordvocab,
              "delta": deltavocab,
              "tag": tagvocab,
          }
      )
      return vocab
  
imports: import random
  import logging
  import torch
  from stanza.models.common.bert_embedding import filter_data
  from stanza.models.common.data import map_to_ids, get_long_tensor, sort_all
  from stanza.models.common.vocab import PAD_ID, VOCAB_PREFIX
  from stanza.models.pos.vocab import CharVocab, CompositeVocab, WordVocab
  from stanza.models.ner.vocab import MultiVocab
  from stanza.models.common.doc import *
  from stanza.models.ner.utils import process_tags, normalize_empty_tags
label_desc: Use image node_id 2 for calling the DataLoader obj's underlying member method code with example usage: obj.init_vocab(data) and returns: vocab, state_dict, state_dict