code: def test_sparsemax_of_inf(dtype):
      """check sparsemax is infinity safe."""
      z_neg = np.asarray(
          [
              [0, -np.inf, 0],
              [0, -np.inf, -np.inf],
              [-np.inf, -np.inf, -np.inf],
          ]
      ).astype(dtype)
      z_pos = np.asarray(
          [
              [0, np.inf, 0],
              [0, np.inf, np.inf],
              [np.inf, np.inf, np.inf],
          ]
      ).astype(dtype)
      z_mix = np.asarray(
          [
              [0, np.inf, 0],
              [0, np.inf, -np.inf],
              [-np.inf, np.inf, -np.inf],
          ]
      ).astype(dtype)
  
      tf_sparsemax_neg = sparsemax(z_neg)
      np.testing.assert_equal(
          np.array(
              [[0.5, 0, 0.5], [1, 0, 0], [np.nan, np.nan, np.nan]]
          ),
          tf_sparsemax_neg,
      )
  
      tf_sparsemax_pos = sparsemax(z_pos)
      np.testing.assert_equal(
          np.array(
              [
                  [np.nan, np.nan, np.nan],
                  [np.nan, np.nan, np.nan],
                  [np.nan, np.nan, np.nan],
              ]
          ),
          tf_sparsemax_pos,
      )
  
      tf_sparsemax_mix = sparsemax(z_mix)
      np.testing.assert_equal(
          np.array(
              [
                  [np.nan, np.nan, np.nan],
                  [np.nan, np.nan, np.nan],
                  [np.nan, np.nan, np.nan],
              ]
          ),
          tf_sparsemax_mix,
      )
  
file_path: addons/tensorflow_addons/activations/tests/sparsemax_test.py
imports: import pytest
  import numpy
  import tensorflow
  from tensorflow_addons.activations import sparsemax
  from tensorflow_addons.utils import test_utils
label_desc: Use image node_id 7 for calling a global function with example usage: test_sparsemax_of_inf(dtype) without return types