code: def HardSigmoid():
      r"""Returns a layer that computes a linear approximation to `Sigmoid`.
  
    .. math::
        f(x) = \left\{ \begin{array}{cl}
            0 & \text{if}\ x \leq 0, \\
            x & \text{if}\ 0 < x < 1, \\
            1 & \text{otherwise}.
        \end{array} \right.
    """
      return Fn(
          "HardSigmoid",
          lambda x: jnp.maximum(0, jnp.minimum(1, (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 10 for calling a global function with example usage: HardSigmoid() and returns: Fn