code: def test_sparsemax_loss_against_numpy(dtype):
      """check sparsemax-loss kernel 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
  
      tf_loss_op, tf_loss_out = _tf_sparsemax_loss(z, q, dtype)
      np_loss = _np_sparsemax_loss(z, q).astype(dtype)
  
      test_utils.assert_allclose_according_to_type(np_loss, tf_loss_out)
      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 8 for calling a global function with example usage: test_sparsemax_loss_against_numpy(dtype) without return types