def _get_schema_annotations_common(tensor_annotation_keys, type_urls,
                                   proto_values):
  """Fetch extra_metadata annotations to be applied to the schema.

  Args:
    tensor_annotation_keys: A list containing either
      `_TF_METADATA_EXTRA_ANNOTATION_GLOBAL` or a hashed tensor representation
      corresponding to each entry in `proto_values`. If an entry
      is`_TF_METADATA_EXTRA_ANNOTATION_GLOBAL`, the corresponding any_pb2.Any
      proto in `proto_values` is returned in `global_annotations`. Otherwise, it
      is returned in `feature_annotations`.
    type_urls: A list of type urls corresponding to the serialized protos in
      `proto_values`.
    proto_values: A list of serialized any_pb2.Any protos.

  Returns:
    A tuple of:
    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.
  """
  tensor_annotations = collections.defaultdict(list)
  global_annotations = []
  if not common.IS_ANNOTATIONS_PB_AVAILABLE:
    return tensor_annotations, global_annotations
  assert len(tensor_annotation_keys) == len(type_urls) == len(proto_values)
  for (tensor_annotation_key, type_url,
       proto_value) in zip(tensor_annotation_keys, type_urls, proto_values):
    annotation = any_pb2.Any(type_url=type_url, value=proto_value)
    if (isinstance(_TF_METADATA_EXTRA_ANNOTATION_GLOBAL,
                   type(tensor_annotation_key)) and
        tensor_annotation_key == _TF_METADATA_EXTRA_ANNOTATION_GLOBAL):
      global_annotations.append(annotation)
    else:
      tensor_annotations[tensor_annotation_key].append(annotation)
  return tensor_annotations, global_annotations
Fetch extra_metadata annotations to be applied to the schema.

  Args:
    tensor_annotation_keys: A list containing either
      `_TF_METADATA_EXTRA_ANNOTATION_GLOBAL` or a hashed tensor representation
      corresponding to each entry in `proto_values`. If an entry
      is`_TF_METADATA_EXTRA_ANNOTATION_GLOBAL`, the corresponding any_pb2.Any
      proto in `proto_values` is returned in `global_annotations`. Otherwise, it
      is returned in `feature_annotations`.
    type_urls: A list of type urls corresponding to the serialized protos in
      `proto_values`.
    proto_values: A list of serialized any_pb2.Any protos.

  Returns:
    A tuple of:
    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