code: def hardtanh(
      x: Union[ivy.Array, ivy.NativeArray],
      /,
      *,
      max_val: float = 1,
      min_val: float = -1,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Apply the hardtanh unit function element-wise.
  
      Parameters
      ----------
      x
          Input array.
      min_val
          minimum value of the linear region range. Default: -1.
      max_val
          maximum value of the linear region range. Default: 1.
      out
          optional output array, for writing the result to. It must have a shape that the
          inputs broadcast to.
  
      Returns
      -------
      ret
          The input array with elu applied element-wise.
  
      Examples
      --------
      With :class:`ivy.Array` input:
      >>> x = ivy.array([0.39, -0.85])
      >>> y = ivy.hardtanh(x)
      >>> print(y)
      ivy.array([ 0.39, -0.85])
      >>> x = ivy.array([1.5, 0.7, -2.4])
      >>> y = ivy.zeros(3)
      >>> ivy.hardtanh(x, out=y)
      >>> print(y)
      ivy.array([ 1., 0.7, -1.])
      >>> x = ivy.array([[1.1, 2.2, 3.3],
      ...                [-0.4, 0.5, -6.6]])
      >>> ivy.hardtanh(x, out=x)
      >>> print(x)
      ivy.array([[ 1.,  1., 1.],
             [-0.4, 0.5, -1.]])
      With :class:`ivy.Container` input:
      >>> x = ivy.Container(a=ivy.array([0.0, -1.2]), b=ivy.array([0.4, -0.2]))
      >>> x = ivy.hardtanhx, out=x)
      >>> print(x)
      {
          a: ivy.array([0., -1.]),
          b: ivy.array([0.4, -0.2])
      }
      """
      return current_backend(x).hardtanh(
          x, max_val=max_val, min_val=min_val, out=out
      )
  
imports: from typing import Union, Optional, Callable, Literal
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.utils.exceptions import handle_exceptions
  from ivy.func_wrapper import handle_array_function, handle_nestable, to_native_arrays_and_back, handle_array_like_without_promotion, handle_out_argument, inputs_to_ivy_arrays, handle_device, handle_backend_invalid, handle_complex_input
label_desc: Use image node_id 11 for calling a global function with example usage: hardtanh() and returns: current_backend