code: def hardtanh(
      x: paddle.Tensor,
      /,
      *,
      max_val: float = 1.0,
      min_val: float = -1.0,
      out: Optional[paddle.Tensor] = None,
  ) -> paddle.Tensor:
      if x.dtype in [paddle.float32, paddle.float64]:
          return F.hardtanh(x, min=min_val, max=max_val)
  
      if paddle.is_complex(x):
          ret = (
              paddle_backend.where(
                  paddle_backend.greater(x, max_val),
                  max_val,
                  paddle_backend.where(
                      paddle_backend.less(x, min_val), min_val, x
                  ),
              ),
          )
          return ret
      return F.hardtanh(
          x.cast("float32"), min=min_val, max=max_val
      ).cast(x.dtype)
  
file_path: ivy/ivy/functional/backends/paddle/experimental/activations.py
imports: from typing import Optional, Union, Literal
  import paddle
  import paddle.nn.functional
  import ivy.functional.backends.paddle
  from ivy.func_wrapper import with_unsupported_device_and_dtypes, with_supported_dtypes, with_supported_device_and_dtypes
  from .None import backend_version
label_desc: Use image node_id 8 for calling a global function with example usage: hardtanh() and returns: F, F, ret