def deref_tensor_or_op(tensor_or_op):
  """Returns a Tensor or CompositeTensor if given a reference, otherwise input.

  Args:
    tensor_or_op: An output of `hashable_tensor_or_op`.

  Returns:
    A Tensor, CompositeTensor, or the given tensor_or_op.
  """
  if isinstance(tensor_or_op, object_identity.Reference):
    return tensor_or_op.deref()
  if isinstance(tensor_or_op, _CompositeTensorRef):
    return tf.nest.pack_sequence_as(
        structure=tensor_or_op.type_spec,
        flat_sequence=[
            deref_tensor_or_op(component)
            for component in tensor_or_op.list_of_refs
        ],
        expand_composites=True)
  return tensor_or_op
Returns a Tensor or CompositeTensor if given a reference, otherwise input.

  Args:
    tensor_or_op: An output of `hashable_tensor_or_op`.

  Returns:
    A Tensor, CompositeTensor, or the given tensor_or_op.
  
tensorflow_transform/tf_utils.py