parameters: (pred: Tensor, label: Tensor, reduction: str = "mean")
return_statement: return diff ** 2
docstring: r"""Calculates the mean squared error (squared L2 norm) between
      each element in the pred :math:`x` and label :math:`y`.
  
      The mean squared error can be described as:
  
      .. math::
  
         \ell(x, y) = mean\left( L \right)
  
      where
  
      .. math::
  
         L = \{l_1,\dots,l_N\}, \quad
         l_n = \left( x_n - y_n \right)^2,
  
      :math:`x` and :math:`y` are tensors of arbitrary shapes with a total
      of :math:`N` elements each. :math:`N` is the batch size.
  
      Args:
          pred: predicted result from model.
          label: ground truth to compare.
          reduction: the reduction to apply to the output: 'none' | 'mean' | 'sum'. Default: 'mean'
  
      Returns:
          loss value.
  
      Shape:
        * pred: :math:`(N, *)` where :math:`*` means any number of additional
          dimensions.
        * label: :math:`(N, *)`. Same shape as ``pred``.
  
      Examples:
  
          .. testcode::
  
              import numpy as np
              import megengine as mge
              import megengine.functional as F
  
              ipt = mge.tensor(np.array([3, 3, 3, 3]).astype(np.float32))
              tgt = mge.tensor(np.array([2, 8, 6, 1]).astype(np.float32))
              loss = F.nn.square_loss(ipt, tgt)
              print(loss.numpy())
  
          Outputs:
  
          .. testoutput::
  
              9.75
docstring_summary: r"""Calculates the mean squared error (squared L2 norm) between
      each element in the pred :math:`x` and label :math:`y`.
docstring_tokens: r Calculates the mean squared error ( squared L2 norm ) between each element in the pred : math : x and label : math : y .
function: def square_loss(pred: Tensor, label: Tensor, reduction: str = "mean") -> Tensor:
      r"""Calculates the mean squared error (squared L2 norm) between
      each element in the pred :math:`x` and label :math:`y`.
  
      The mean squared error can be described as:
  
      .. math::
  
         \ell(x, y) = mean\left( L \right)
  
      where
  
      .. math::
  
         L = \{l_1,\dots,l_N\}, \quad
         l_n = \left( x_n - y_n \right)^2,
  
      :math:`x` and :math:`y` are tensors of arbitrary shapes with a total
      of :math:`N` elements each. :math:`N` is the batch size.
  
      Args:
          pred: predicted result from model.
          label: ground truth to compare.
          reduction: the reduction to apply to the output: 'none' | 'mean' | 'sum'. Default: 'mean'
  
      Returns:
          loss value.
  
      Shape:
        * pred: :math:`(N, *)` where :math:`*` means any number of additional
          dimensions.
        * label: :math:`(N, *)`. Same shape as ``pred``.
  
      Examples:
  
          .. testcode::
  
              import numpy as np
              import megengine as mge
              import megengine.functional as F
  
              ipt = mge.tensor(np.array([3, 3, 3, 3]).astype(np.float32))
              tgt = mge.tensor(np.array([2, 8, 6, 1]).astype(np.float32))
              loss = F.nn.square_loss(ipt, tgt)
              print(loss.numpy())
  
          Outputs:
  
          .. testoutput::
  
              9.75
      """
      diff = pred - label
      return diff ** 2
function_tokens: def square_loss ( pred : Tensor , label : Tensor , reduction : str = "mean" ) -> Tensor : diff = pred - label return diff ** 2