code: def test_loss_ndarray():
      output = mx.np.array([1, 2, 3, 4])
      label = mx.np.array([1, 3, 5, 7])
      weighting = mx.np.array([0.5, 1, 0.5, 1])
  
      loss = gluon.loss.L1Loss()
      assert mx.np.sum(loss(output, label)).item() == 6.0
      loss = gluon.loss.L1Loss(weight=0.5)
      assert mx.np.sum(loss(output, label)).item() == 3.0
      loss = gluon.loss.L1Loss()
      assert mx.np.sum(loss(output, label, weighting)).item() == 5.0
  
      loss = gluon.loss.L2Loss()
      assert mx.np.sum(loss(output, label)).item() == 7.0
      loss = gluon.loss.L2Loss(weight=0.25)
      assert mx.np.sum(loss(output, label)).item() == 1.75
      loss = gluon.loss.L2Loss()
      assert mx.np.sum(loss(output, label, weighting)).item() == 6
  
      output = mx.np.array([[0, 2], [1, 4]])
      label = mx.np.array([0, 1])
      weighting = mx.np.array([[0.5], [1.0]])
  
      loss = gluon.loss.SoftmaxCrossEntropyLoss()
      L = loss(output, label).asnumpy()
      assert_almost_equal(
          L, onp.array([2.12692809, 0.04858733]), rtol=1e-3, atol=1e-4
      )
  
      L = loss(output, label, weighting).asnumpy()
      assert_almost_equal(
          L, onp.array([1.06346405, 0.04858733]), rtol=1e-3, atol=1e-4
      )
  
file_path: mxnet/tests/python/unittest/test_loss.py
imports: import mxnet
  import numpy
  from mxnet import gluon, autograd
  from mxnet.test_utils import assert_almost_equal, default_device
  from numpy.core.fromnumeric import size
  from common import xfail_when_nonstandard_decimal_separator
  import unittest
label_desc: Use image node_id 1 for calling a global function with example usage: test_loss_ndarray() without return types