code: def load_vocab(path: Text) -> Tuple[Dict[Text, int], Dict[int, Text]]:
      """Loads the vocabulary from the specified path.
  
      Args:
        path: The path to the vocabulary file. If the file has a tfrecord.gz suffix,
          we assume it is a GZIP-compressed TFRecord file. Otherwise, we assume it
          is a text file.
  
      Returns:
        A tuple where the first element is a dictionary specifying the string token
        to integer mapping and the second element represents the reverse lookup
        (i.e. integer token to string mapping).
  
      Raises:
        ValueError: Vocabulary path does not exist.
      """
      vocab = {}
      reverse_vocab = {}
  
      if not tf.io.gfile.exists(path):
          raise ValueError("Vocabulary path: %s does not exist" % path)
  
      def populate_entry(index, entry):
          entry = six.ensure_text(entry).strip()
          vocab[entry] = index
          reverse_vocab[index] = entry
  
      if path.endswith("tfrecord.gz"):
          data_iter = tf.compat.v1.io.tf_record_iterator(
              path, tf.io.TFRecordOptions(compression_type="GZIP")
          )
          for index, entry in enumerate(data_iter):
              populate_entry(index, entry)
      else:
          with tf.io.gfile.GFile(path) as f:
              for index, entry in enumerate(f):
                  populate_entry(index, entry)
      return vocab, reverse_vocab
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Dict, Text, Tuple
  import six
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: load_vocab(path) and returns: vocab,  reverse_vocab