code: def clip(
      x: Union[tf.Tensor, tf.Variable],
      /,
      x_min: Optional[Union[Number, tf.Tensor, tf.Variable]] = None,
      x_max: Optional[Union[Number, tf.Tensor, tf.Variable]] = None,
      *,
      out: Optional[Union[tf.Tensor, tf.Variable]] = None,
  ) -> Union[tf.Tensor, tf.Variable]:
      if x_min is None and x_max is None:
          raise ValueError(
              "At least one of the x_min or x_max must be provided"
          )
      promoted_type = x.dtype
      if x_min is not None:
          if not hasattr(x_min, "dtype"):
              x_min = ivy.array(x_min).data
          promoted_type = ivy.as_native_dtype(
              ivy.promote_types(x.dtype, x_min.dtype)
          )
      if x_max is not None:
          if not hasattr(x_max, "dtype"):
              x_max = ivy.array(x_max).data
          promoted_type = ivy.as_native_dtype(
              ivy.promote_types(promoted_type, x_max.dtype)
          )
          x_max = tf.cast(x_max, promoted_type)
      x = tf.cast(x, promoted_type)
      if x_min is not None:
          x_min = tf.cast(x_min, promoted_type)
      cond = True
      if x_min is not None and x_max is not None:
          if tf.math.reduce_any(
              tf.experimental.numpy.greater(x_min, x_max)
          ):
              cond = False
      if cond:
          return tf.experimental.numpy.clip(x, x_min, x_max)
      else:
          return tf.experimental.numpy.minimum(
              x_max, tf.experimental.numpy.maximum(x, x_min)
          )
  
imports: import math
  from numbers import Number
  from typing import Union, Tuple, Optional, List, Sequence
  import numpy
  import tensorflow
  import ivy
  from ivy.func_wrapper import with_unsupported_dtypes
  from ivy.functional.ivy.manipulation import _calculate_out_shape
  from .None import backend_version
label_desc: Use image node_id 16 for calling a global function with example usage: clip(x_min, x_max) and returns: tf, tf