code: def _convert_or_cast(x, dtype, name):
      """Converts/casts the input x to dtype."""
      # math_ops.cast calls convert_to_tensor(x) under the hood, which can cause
      # infinite recursion if non-Tensor inputs are passed into tf.constant.
      # For example, tf.constant([1, 2, 3]) -> cast([1, 2, 3], tf.int32) ->
      # convert_to_tensor([1, 2, 3]) -> tf.constant([1, 2, 3])...
      if isinstance(x, weak_tensor.WeakTensor):
          x = x.to_tensor()
      # CompositeTensor needs to call math_ops.cast because math_ops.cast may
      # have a dispatch for that CompositeTensor.
      if isinstance(x, core.Tensor) or isinstance(
          x, composite_tensor.CompositeTensor
      ):
          return math_ops.cast(x, dtype=dtype, name=name)
      else:
          return ops.convert_to_tensor(x, dtype=dtype, name=name)
  
imports: import inspect
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import flexible_dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import weak_tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import clip_ops
  from tensorflow.python.ops import gen_array_ops
  from tensorflow.python.ops import gen_bitwise_ops
  from tensorflow.python.ops import gen_math_ops
  from tensorflow.python.ops import image_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_impl
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import special_math_ops
  from tensorflow.python.ops.numpy_ops import np_array_ops
  from tensorflow.python.ops.numpy_ops import np_math_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import core
  from tensorflow.python.util import dispatch
  from tensorflow.python.util import tf_decorator
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_or_cast(x, dtype, name) and returns: math_ops, ops