r"""Clip inputs by values.

    .. math::

        y = \begin{cases}
                max & (x > max) \\
                x & (otherwise) \\
                min & (x < min)
            \end{cases}.

    Args:
        x (Variable): An input variable.
        min (Variable): A min variable by which `x` is clipped. Note that the shape of `min` must be the same as `x`'s.
        max (Variable): A max variable by which `x` is clipped. Note that the shape of `max` must be the same as `x`'s

    Returns:
        ~nnabla.Variable: N-D array.

def clip_by_value(x, min, max):
    r"""Clip inputs by values.

    .. math::

        y = \begin{cases}
                max & (x > max) \\
                x & (otherwise) \\
                min & (x < min)
            \end{cases}.

    Args:
        x (Variable): An input variable.
        min (Variable): A min variable by which `x` is clipped. Note that the shape of `min` must be the same as `x`'s.
        max (Variable): A max variable by which `x` is clipped. Note that the shape of `max` must be the same as `x`'s

    Returns:
        ~nnabla.Variable: N-D array.

    """
    from .function_bases import maximum2 as maximum2_base
    from .function_bases import minimum2 as minimum2_base
    return minimum2_base(maximum2_base(x, min), max)