code: def test_cosine_loss(hybridize):
      # Generating samples
      input1 = mx.np.random.randn(3, 2)
      input2 = mx.np.random.randn(3, 2)
      label = mx.np.sign(mx.np.random.randn(input1.shape[0]))
      # Calculating loss from cosine embedding loss function in Gluon
      Loss = gluon.loss.CosineEmbeddingLoss()
      if hybridize:
          Loss.hybridize()
      loss = Loss(input1, input2, label)
  
      # Calculating the loss Numpy way
      numerator = mx.np.sum(input1 * input2, keepdims=True, axis=1)
      denominator = mx.np.sqrt(
          mx.np.sum(input1**2, axis=1, keepdims=True)
      ) * mx.np.sqrt(mx.np.sum(input2**2, axis=1, keepdims=True))
      x = numerator / denominator
      label = mx.npx.reshape(label, (-1, 1))
      numpy_loss = mx.npx.reshape(
          mx.np.where(label == 1, 1 - x, mx.npx.relu(x)), (-1,)
      )
      assert_almost_equal(
          loss.asnumpy(), numpy_loss.asnumpy(), rtol=1e-3, atol=1e-5
      )
  
file_path: mxnet/tests/python/unittest/test_numpy_loss.py
imports: import mxnet
  import numpy
  from mxnet import gluon, autograd
  from mxnet.test_utils import assert_almost_equal, default_device, use_np
  from common import xfail_when_nonstandard_decimal_separator
  import pytest
label_desc: Use image node_id 6 for calling a global function with example usage: test_cosine_loss(hybridize) without return types