code: def load_vocab(vocab: Union[str, Vocab]) -> Vocab:
      """Quick helper function to load vocabulary from a file.
  
      Parameters
      ----------
      vocab
  
      Returns
      -------
  
      """
      if isinstance(vocab, Vocab):
          return vocab
      elif isinstance(vocab, str):
          return Vocab.load(vocab)
      else:
          raise NotImplementedError(
              "Type of the input vocab is not supported. "
              'We only support "str" or "Vocab". type(vocab) = "{}".'.format(
                  type(vocab)
              )
          )
  
imports: import collections
  import json
  import warnings
  import numpy
  from typing import Dict, Hashable, List, Optional, Counter, Union, Tuple
label_desc: Use image node_id 2 for calling a global function with example usage: load_vocab(vocab) and returns: vocab, Vocab