code: def test_sparse_getnnz():
      if default_device().device_type is "gpu":
          return
  
      def check_sparse_getnnz(density, axis):
          shape = rand_shape_2d()
          data = rand_ndarray(shape, "csr", density=density)
          data_sp = data.asscipy()
          result = mx.nd.contrib.getnnz(data, axis=axis)
          expected_result = data_sp.getnnz(axis=axis)
          assert_almost_equal(result.asnumpy(), expected_result)
  
      densities = [0, 0.5, 1]
      axis = [1, None]
      for d in densities:
          for a in axis:
              check_sparse_getnnz(d, a)
  
imports: import pickle
  from mxnet.ndarray import NDArray
  import mxnet
  from mxnet.test_utils import *
  from common import random_seed
  from mxnet.base import mx_real_t
  from numpy.testing import assert_allclose
  import numpy.random
  import numpy
  import scipy.sparse
  from common import assertRaises, xfail_when_nonstandard_decimal_separator
  from mxnet.ndarray.sparse import RowSparseNDArray, CSRNDArray
  import pytest
label_desc: Use image node_id 41 for calling a global function with example usage: test_sparse_getnnz() without return types