code: def hard_sigmoid(x):
      """Element-wise hard-sigmoid function.
  
      This function is defined as
  
      .. math::
  
          f(x) = \\left \\{ \\begin{array}{ll}
          0 & {\\rm if}~ x < -2.5 \\\\
          0.2 x + 0.5 & {\\rm if}~ -2.5 < x < 2.5 \\\\
          1 & {\\rm if}~ 2.5 < x.
          \\end{array} \\right.
  
      Args:
          x (:class:`~chainer.Variable` or :ref:`ndarray`):
              Input variable. A :math:`(s_1, s_2, ..., s_N)`-shaped float array.
  
      Returns:
          ~chainer.Variable: Output variable. A
          :math:`(s_1, s_2, ..., s_N)`-shaped float array.
  
      .. admonition:: Example
  
          It maps the input values into the range of :math:`[0, 1]`.
  
          >>> x = np.array([-2.6, -1, 0, 1, 2.6])
          >>> x
          array([-2.6, -1. ,  0. ,  1. ,  2.6])
          >>> F.hard_sigmoid(x).array
          array([0. , 0.3, 0.5, 0.7, 1. ])
  
      """
      return HardSigmoid().apply((x,))[0]
  
file_path: chainer/chainer/functions/activation/hard_sigmoid.py
imports: import numpy
  from chainer.backends import cuda
  from chainer import function_node
  from chainer import utils
  from chainer.utils import type_check
label_desc: Use image node_id 1 for calling a global function with example usage: hard_sigmoid(x) and returns: HardSigmoid