def _get_schema_annotations_v2(metadata):
  """Fetch extra_metadata annotations to be applied to the schema.

  Extracts any deferred annotations that have been added to the graph and
  evaluates them to obtain any_pb2.Any proto messages.

  Args:
    metadata: A dictionary containing the deferred annotations added to the
      graph.

  Returns:
    tensor_annotations: dictionary from tensor to list of any_pb2.Any protos to
      be added as an annotation for that tensor's feature in the schema.
    global_annotations: list of any_pb2.Any protos to be added at the global
      schema level.
  """
  type_urls = [
      type_url.numpy()
      for type_url in metadata[_TF_METADATA_EXTRA_ANNOTATION_TYPE_URL]
  ]
  proto_values = [
      proto_value.numpy()
      for proto_value in metadata[_TF_METADATA_EXTRA_ANNOTATION_PROTO]
  ]
  tensor_annotation_keys = [
      tensor.numpy().decode()
      for tensor in metadata[_TF_METADATA_EXTRA_ANNOTATION]
  ]
  return _get_schema_annotations_common(tensor_annotation_keys, type_urls,
                                        proto_values)
Fetch extra_metadata annotations to be applied to the schema.

  Extracts any deferred annotations that have been added to the graph and
  evaluates them to obtain any_pb2.Any proto messages.

  Args:
    metadata: A dictionary containing the deferred annotations added to the
      graph.

  Returns:
    tensor_annotations: dictionary from tensor to list of any_pb2.Any protos to
      be added as an annotation for that tensor's feature in the schema.
    global_annotations: list of any_pb2.Any protos to be added at the global
      schema level.
  
tensorflow_transform/schema_inference.py