code: def test_vocab_annotation(self, use_compat_v1):
      if not use_compat_v1:
          test_case.skip_if_not_tf2("Tensorflow 2.x required")
  
      def preprocessing_fn(_):
          analyzers._maybe_annotate_vocab_metadata(
              "file1",
              tf.constant(100, dtype=tf.int64),
              tf.constant(75, dtype=tf.int64),
          )
          analyzers._maybe_annotate_vocab_metadata(
              "file2",
              tf.constant(200, dtype=tf.int64),
              tf.constant(175, dtype=tf.int64),
          )
          return {
              "foo": tf.convert_to_tensor([0, 1, 2, 3], dtype=tf.int64),
          }
  
      schema = self._get_schema(
          preprocessing_fn, use_compat_v1, create_session=True
      )
      self.assertLen(schema.annotation.extra_metadata, 2)
      unfiltered_sizes = {}
      filtered_sizes = {}
      for annotation in schema.annotation.extra_metadata:
          message = annotations_pb2.VocabularyMetadata()
          annotation.Unpack(message)
          unfiltered_sizes[
              message.file_name
          ] = message.unfiltered_vocabulary_size
          filtered_sizes[
              message.file_name
          ] = message.filtered_vocabulary_size
      self.assertDictEqual(
          unfiltered_sizes, {"file1": 100, "file2": 200}
      )
      self.assertDictEqual(filtered_sizes, {"file1": 75, "file2": 175})
  
imports: import functools
  import os
  import tensorflow
  from tensorflow_transform import analyzers
  from tensorflow_transform import common
  from tensorflow_transform import graph_context
  from tensorflow_transform import mappers
  from tensorflow_transform import schema_inference
  from tensorflow_transform import tf2_utils
  from tensorflow_transform import test_case
  from tensorflow_transform.tf_metadata import schema_utils_legacy
  from tensorflow_transform.tf_metadata import schema_utils
  from google.protobuf import text_format
  import unittest
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 4 for calling the SchemaInferenceTest obj's underlying member method code with example usage: obj.test_vocab_annotation(use_compat_v1) and returns: dict