code: def is_valid_vocab(vocab: Vocab) -> bool:
      """
      Checks if a vocabulary is valid. We define valid as:
      1. All indices from 0 to num_words - 1 are present without duplicates.
      2. PAD_SYMBOL has word id 0, UNK_SYMBOL has word id 1, BOS_SYMBOL has word id 2, EOS_SYMBOL has word id 3.
      """
      if vocab[C.PAD_SYMBOL] != C.PAD_ID:
          logger.warning(
              "PAD_SYMBOL does not have word id 0 in vocabulary."
          )
          return False
      if vocab[C.UNK_SYMBOL] != C.UNK_ID:
          logger.warning(
              "UNK_SYMBOL does not have word id 1 in vocabulary."
          )
          return False
      if vocab[C.BOS_SYMBOL] != C.BOS_ID:
          logger.warning(
              "BOS_SYMBOL does not have word id 2 in vocabulary."
          )
          return False
      if vocab[C.EOS_SYMBOL] != C.EOS_ID:
          logger.warning(
              "EOS_SYMBOL does not have word id 3 in vocabulary."
          )
          return False
      word_ids = []
      for word, word_id in vocab.items():
          word_ids.append(word_id)
      word_ids_set = set(word_ids)
      if len(word_ids_set) != len(word_ids):
          logger.warning("Duplicate word_ids in vocabulary.")
          return False
  
      expected_word_ids = set(range(0, len(vocab)))
      if expected_word_ids != word_ids_set:
          logger.warning(
              "Not all word_ids from 0 to len(vocabulary) present in vocabulary."
          )
          return False
  
      return True
  
imports: import argparse
  import json
  import logging
  import os
  from collections import Counter
  from itertools import chain, islice
  from typing import Dict, Iterable, List, Optional, Tuple, Callable
  from sockeye.log import setup_main_logger
  from .None import constants
  from .None import utils
label_desc: Use image node_id 7 for calling a global function with example usage: is_valid_vocab(vocab) and returns: True, False, False, False, False, False, False