code: def composite_tensor_info_to_type_spec(tensor_info):
      """Converts a `TensorInfo` for a composite tensor to a `TypeSpec` object."""
      if nested_structure_coder is None or struct_pb2 is None:
          raise ValueError(
              "This version of TensorFlow does not support "
              "composite tensors."
          )
      if tensor_info.WhichOneof("encoding") != "composite_tensor":
          raise ValueError(
              "Expected a TensorInfo with encoding=composite_tensor"
          )
      spec_proto = struct_pb2.StructuredValue(
          type_spec_value=tensor_info.composite_tensor.type_spec
      )
      # StrcutureCoder.decode_proto was migrated after TF 2.7 to
      # nested_structure_coder.decode_proto.
      try:
          return nested_structure_coder.decode_proto(spec_proto)
      except AttributeError:
          struct_coder = nested_structure_coder.StructureCoder()
          return struct_coder.decode_proto(spec_proto)
  
file_path: hub/tensorflow_hub/tf_utils.py
imports: import os
  import time
  import uuid
  from absl import logging
  import tensorflow
label_desc: Use image node_id 10 for calling a global function with example usage: composite_tensor_info_to_type_spec(tensor_info) and returns: nested_structure_coder, struct_coder