code: def _get_vocabulary(
      tokenizer_type: str,
      tokenizer,
      vocab_file: str,
      unknown_symbol: str,
      add_special_symbols: bool,
      padding_symbol: str,
      unit_counts: Counter,
      num_most_frequent: int,
  ) -> Optional[List[str]]:
      """Returns the vocabulary from the tokenizer_type, tokenizer, or vocab_file.
  
      If the `tokenizer_type` is 'hf_tokenizer', then the set vocabulary from the tokenizer is used.
  
      If there's no vocab_file or if the tokenizer has no set vocabulary (e.g. space_punct), then the vocabulary is
      determined from the tokenized data (unit_counts).
  
      The UNKNOWN special symbol is always included in the final vocabulary. Additional special symbols (PADDING, START,
      STOP) are added if add_special_symbols=True. If the tokenizer is a pre-trained huggingface tokenizer, then the
      special symbols are taken from the tokenizer's vocabulary.
      """
      # Pre-trained huggingface tokenizer. Use the pre-existing vocabulary and special symbols.
      if tokenizer_type == "hf_tokenizer":
          try:
              return _get_vocab_from_dict(tokenizer.get_vocab())
          except NotImplementedError:
              logger.warning(
                  "HuggingFace tokenizer does not have a get_vocab() method. "
                  + "Using tokenizer.tokenizer.vocab_size and tokenizer.tokenizer._convert_id_to_token "
                  + "to build the vocabulary."
              )
              vocab = []
              for idx in range(tokenizer.tokenizer.vocab_size):
                  vocab.append(
                      tokenizer.tokenizer._convert_id_to_token(idx)
                  )
              vocab += tokenizer.tokenizer.added_tokens_encoder.keys()
              return vocab
  
      # The tokenizer has a preset vocabulary.
      if hasattr(tokenizer, "get_vocab"):
          return _get_vocab_from_dict(tokenizer.get_vocab())
  
      # Load the vocabulary from the vocab file.
      if vocab_file is not None:
          return load_vocabulary(vocab_file)
  
      # The tokenizer had no preset vocabulary, for example space_punct.
      # Compute the vocabulary from tokenized data.
      return [
          unit for unit, _ in unit_counts.most_common(num_most_frequent)
      ]
  
imports: import logging
  import re
  import unicodedata
  from collections import Counter
  from dataclasses import dataclass
  from enum import Enum
  from typing import Dict, List, Optional, Set, Union
  import numpy
  from dateutil.parser import parse
  from ludwig.constants import PADDING_SYMBOL, START_SYMBOL, STOP_SYMBOL, UNKNOWN_SYMBOL
  from ludwig.data.dataframe.base import DataFrameEngine
  from ludwig.data.dataframe.pandas import PANDAS
  from ludwig.utils.fs_utils import open_file
  from ludwig.utils.math_utils import int_type
  from ludwig.utils.tokenizers import get_tokenizer_from_registry
  from ludwig.utils.types import Series
label_desc: Use image node_id 18 for calling a global function with example usage: _get_vocabulary(tokenizer_type, tokenizer, vocab_file, unknown_symbol, add_special_symbols, padding_symbol, unit_counts, num_most_frequent) and returns: unknown, _get_vocab_from_dict, load_vocabulary, _get_vocab_from_dict, vocab