def norm_l1(x, axis=None):
    r"""Compute the :math:`\ell_1` norm

    .. math::
     \| \mathbf{x} \|_1 = \sum_i | x_i |

    where :math:`x_i` is element :math:`i` of vector :math:`\mathbf{x}`.


    Parameters
    ----------
    x : array_like
      Input array :math:`\mathbf{x}`
    axis : `None` or int or tuple of ints, optional (default None)
      Axes of `x` over which to compute the :math:`\ell_1` norm. If
      `None`, an entire multi-dimensional array is treated as a
      vector. If axes are specified, then distinct values are computed
      over the indices of the remaining axes of input array `x`.

    Returns
    -------
    nl1 : float or ndarray
      Norm of `x`, or array of norms treating specified axes of `x`
      as a vector
    """

    nl1 = np.sum(np.abs(x), axis=axis, keepdims=True)
    # If the result has a single element, convert it to a scalar
    if nl1.size == 1:
        nl1 = nl1.ravel()[0]
    return nl1