code: def test_NDArrayIter_csr():
      # creating toy data
      num_rows = rnd.randint(5, 15)
      num_cols = rnd.randint(1, 20)
      batch_size = rnd.randint(1, num_rows)
      shape = (num_rows, num_cols)
      csr, _ = rand_sparse_ndarray(shape, "csr")
      dns = csr.asnumpy()
  
      # CSRNDArray or scipy.sparse.csr_matrix with last_batch_handle not equal to 'discard' will throw NotImplementedError
      assertRaises(
          NotImplementedError,
          mx.io.NDArrayIter,
          {"data": csr},
          dns,
          batch_size,
      )
      try:
          import scipy.sparse as spsp
  
          train_data = spsp.csr_matrix(dns)
          assertRaises(
              NotImplementedError,
              mx.io.NDArrayIter,
              {"data": train_data},
              dns,
              batch_size,
          )
      except ImportError:
          pass
  
      # scipy.sparse.csr_matrix with shuffle
      csr_iter = iter(
          mx.io.NDArrayIter(
              {"data": train_data},
              dns,
              batch_size,
              shuffle=True,
              last_batch_handle="discard",
          )
      )
      csr_iter_empty_list = iter(
          mx.io.NDArrayIter(
              {"data": train_data},
              [],
              batch_size,
              shuffle=True,
              last_batch_handle="discard",
          )
      )
      csr_iter_None = iter(
          mx.io.NDArrayIter(
              {"data": train_data},
              None,
              batch_size,
              shuffle=True,
              last_batch_handle="discard",
          )
      )
      _test_NDArrayIter_csr(
          csr_iter,
          csr_iter_empty_list,
          csr_iter_None,
          num_rows,
          batch_size,
      )
  
      # CSRNDArray with shuffle
      csr_iter = iter(
          mx.io.NDArrayIter(
              {"csr_data": csr, "dns_data": dns},
              dns,
              batch_size,
              shuffle=True,
              last_batch_handle="discard",
          )
      )
      csr_iter_empty_list = iter(
          mx.io.NDArrayIter(
              {"csr_data": csr, "dns_data": dns},
              [],
              batch_size,
              shuffle=True,
              last_batch_handle="discard",
          )
      )
      csr_iter_None = iter(
          mx.io.NDArrayIter(
              {"csr_data": csr, "dns_data": dns},
              None,
              batch_size,
              shuffle=True,
              last_batch_handle="discard",
          )
      )
      _test_NDArrayIter_csr(
          csr_iter,
          csr_iter_empty_list,
          csr_iter_None,
          num_rows,
          batch_size,
      )
  
      # make iterators
      csr_iter = iter(
          mx.io.NDArrayIter(
              csr, csr, batch_size, last_batch_handle="discard"
          )
      )
      begin = 0
      for batch in csr_iter:
          expected = np.zeros((batch_size, num_cols))
          end = begin + batch_size
          expected[: num_rows - begin] = dns[begin:end]
          if end > num_rows:
              expected[num_rows - begin :] = dns[0 : end - num_rows]
          assert_almost_equal(batch.data[0].asnumpy(), expected)
          begin += batch_size
  
imports: import mxnet
  import mxnet.ndarray
  from mxnet.test_utils import *
  from mxnet.base import MXNetError
  import numpy
  import os
  import gzip
  import pickle
  import time
  import sys
  from common import assertRaises
  import pytest
  from itertools import zip_longest
label_desc: Use image node_id 13 for calling a global function with example usage: test_NDArrayIter_csr() without return types