code: def test_make_tfrecord_vocabulary_lookup_initializer(
      self, function_handler
  ):
      vocab_file = os.path.join(
          self.get_temp_dir(), "vocab.tfrecord.gz"
      )
      contents = [b"%i" % idx for idx in range(1000)]
      self._write_tfrecords(vocab_file, contents)
  
      input_signature = [tf.TensorSpec(None, tf.string)]
  
      @function_handler(input_signature=input_signature)
      def lookup(x):
          initializer = (
              tf_utils.make_tfrecord_vocabulary_lookup_initializer(
                  vocab_file
              )
          )
          table = tf.lookup.StaticHashTable(initializer, -1)
          return table.lookup(x)
  
      # make_tfrecord_vocabulary_lookup_initializer calls annotators.track_object
      # which expects to be invoked inside an object_tracker_scope.
      with annotators.object_tracker_scope(annotators.ObjectTracker()):
          self.assertEqual(lookup("5"), 5)
          self.assertEqual(lookup("1000"), -1)
  
imports: import os
  import numpy
  from packaging import version
  import tensorflow
  from tensorflow_transform import analyzers
  from tensorflow_transform import annotators
  from tensorflow_transform import tf_utils
  from tensorflow_transform import test_case
  from tensorflow.python.framework import composite_tensor
label_desc: Use image node_id 5 for calling the VocabTFUtilsTest obj's underlying member method code with example usage: obj.test_make_tfrecord_vocabulary_lookup_initializer(function_handler) and returns: table