code: def _convert_tensor(value, path, context):
      """Converts `value` to a `Tensor`."""
      if context == _ConversionContext.SPEC:
          if not (
              isinstance(value, type_spec.TypeSpec)
              and value.value_type is tensor.Tensor
          ):
              raise TypeError(
                  f'{"".join(path)}: expected a TensorSpec, got '
                  f"{type(value).__name__!r}"
              )
          return value
  
      if not isinstance(value, tensor.Tensor):
          if context == _ConversionContext.DEFAULT:
              # TODO(edloper): Convert the value to a numpy array?  (Note: we can't just
              # use `np.array(value)`, since the default dtypes for TF and numpy are
              # different -- e.g., int->np.int64 but int->tf.int32.
              return value
          try:
              value = ops.convert_to_tensor(value)
          except (ValueError, TypeError) as e:
              raise TypeError(
                  f'{"".join(path)}: expected a Tensor, '
                  f"got {type(value).__name__!r}"
              ) from e
      return value
  
imports: import collections
  import collections.abc
  import enum
  import typing
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import immutable_dict
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import type_spec
  from tensorflow.python.util import type_annotations
label_desc: Use image node_id 7 for calling a global function with example usage: _convert_tensor(value, path, context) and returns: value, value, value