code: def clip(
      x: torch.Tensor,
      /,
      x_min: Optional[Union[Number, torch.Tensor]] = None,
      x_max: Optional[Union[Number, torch.Tensor]] = None,
      *,
      out: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      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 = x_max.to(promoted_type)
      x = x.to(promoted_type)
      if x_min is not None:
          x_min = x_min.to(promoted_type)
      return torch.clamp(x, x_min, x_max, out=out)
  
imports: import math
  from numbers import Number
  from typing import Union, Optional, Tuple, List, Sequence, Iterable
  import torch
  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: torch