code: def test_global_annotation(self, use_compat_v1):
      # pylint: enable=g-import-not-at-top
      if not use_compat_v1:
          test_case.skip_if_not_tf2("Tensorflow 2.x required")
  
      def preprocessing_fn(_):
          # Annotate an arbitrary proto at the schema level (not sure what global
          # schema boundaries would mean, but hey I'm just a test).
          boundaries = tf.constant([[1.0]])
          message_type = (
              annotations_pb2.BucketBoundaries.DESCRIPTOR.full_name
          )
          sizes = tf.expand_dims([tf.size(boundaries)], axis=0)
          message_proto = tf.raw_ops.EncodeProto(
              sizes=sizes,
              values=[tf.cast(boundaries, tf.float32)],
              field_names=["boundaries"],
              message_type=message_type,
          )[0]
          type_url = os.path.join("type.googleapis.com", message_type)
          schema_inference.annotate(type_url, message_proto)
          return {
              "foo": tf.convert_to_tensor([0, 1, 2, 3], dtype=tf.int64),
              "bar": tf.convert_to_tensor([0, 2, 0, 2], dtype=tf.int64),
          }
  
      schema = self._get_schema(
          preprocessing_fn, use_compat_v1, create_session=True
      )
      self.assertLen(schema.annotation.extra_metadata, 1)
      for annotation in schema.annotation.extra_metadata:
          # Extract the annotated message and validate its contents
          message = annotations_pb2.BucketBoundaries()
          annotation.Unpack(message)
          self.assertAllClose(list(message.boundaries), [1])
  
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 6 for calling the SchemaInferenceTest obj's underlying member method code with example usage: obj.test_global_annotation(use_compat_v1) and returns: dict