code: def HardTanh():
      r"""Returns a layer that computes a linear approximation to `Tanh`.
  
    .. math::
        f(x) = \left\{ \begin{array}{cl}
            -1 & \text{if}\ x \leq -1, \\
            x  & \text{if}\ -1 < x < 1, \\
            1  & \text{otherwise}.
        \end{array} \right.
    """
      return Fn(
          "HardTanh", lambda x: jnp.maximum(-1, jnp.minimum(1, x))
      )
  
imports: from trax import fastmath
  from trax.fastmath import numpy
  from trax.layers import base
  from trax.layers.assert_shape import assert_shape
  from trax.layers.base import Fn
label_desc: Use image node_id 11 for calling a global function with example usage: HardTanh() and returns: Fn