code: def test_sparsemax_loss_constructor_aginst_numpy(dtype):
      """check sparsemax-loss construcor against numpy."""
      random = np.random.RandomState(1)
  
      z = random.uniform(low=-3, high=3, size=(test_obs, 10))
      q = np.zeros((test_obs, 10))
      q[
          np.arange(0, test_obs), random.randint(0, 10, size=test_obs)
      ] = 1
  
      loss_object = SparsemaxLoss()
      tf_loss_op = loss_object(q, z)
      np_loss = np.mean(_np_sparsemax_loss(z, q).astype(dtype))
  
      test_utils.assert_allclose_according_to_type(np_loss, tf_loss_op)
      assert np_loss.shape == tf_loss_op.shape
  
file_path: addons/tensorflow_addons/losses/tests/sparsemax_loss_test.py
imports: import pytest
  from packaging.version import Version
  import tensorflow
  import numpy
  from tensorflow_addons.activations import sparsemax
  from tensorflow_addons.losses import sparsemax_loss, SparsemaxLoss
  from tensorflow_addons.utils import test_utils
label_desc: Use image node_id 3 for calling a global function with example usage: test_sparsemax_loss_constructor_aginst_numpy(dtype) without return types