code: def norm_2l2(x, axis=None):
      r
  
      nl2 = np.sum(x**2, axis=axis, keepdims=True)
      # If the result has a single element, convert it to a scalar
      if nl2.size == 1:
          nl2 = nl2.ravel()[0]
      return nl2
docs: r"""Compute the squared :math:`\ell_2` norm
  
      .. math::
        \| \mathbf{x} \|_2^2 = \sum_i x_i^2
  
      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_2` 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
      -------
      nl2 : float or ndarray
        Norm of `x`, or array of norms treating specified axes of `x`
        as a vector.