code: def hard_tanh(x: ArrayLike) -> Array:
      r"""Hard :math:`\mathrm{tanh}` activation function.
  
    Computes the element-wise function:
  
    .. math::
      \mathrm{hard\_tanh}(x) = \begin{cases}
        -1, & x < -1\\
        x, & -1 \le x \le 1\\
        1, & 1 < x
      \end{cases}
  
    Args:
      x : input array
  
    Returns:
      An array.
    """
      numpy_util.check_arraylike("hard_tanh", x)
      x_arr = jnp.asarray(x)
      return jnp.where(x_arr > 1, 1, jnp.where(x_arr < -1, -1, x_arr))
  
imports: from __future__ import annotations
  from functools import partial
  import operator
  import numpy
  from typing import Any
  import jax
  import jax.numpy
  from jax import custom_jvp
  from jax import lax
  from jax._src import config
  from jax._src import core
  from jax._src import dtypes
  from jax._src import util
  from jax._src.core import AxisName
  from jax._src.numpy import util
  from jax._src.typing import Array, ArrayLike
  from jax._src.ops.special import logsumexp
label_desc: Use image node_id 10 for calling a global function with example usage: hard_tanh(x) and returns: jnp