code: def test_sparse_nd_check_format():
      """test check_format for sparse ndarray"""
      shape = rand_shape_2d()
      stypes = ["csr", "row_sparse"]
      for stype in stypes:
          arr, _ = rand_sparse_ndarray(shape, stype)
          arr.check_format()
          arr = mx.nd.sparse.zeros(stype, shape)
          arr.check_format()
      # CSR format index pointer array should be less than the number of rows
      shape = (3, 4)
      data_list = [7, 8, 9]
      indices_list = [0, 2, 1]
      indptr_list = [0, 5, 2, 3]
      a = mx.nd.sparse.csr_matrix(
          (data_list, indices_list, indptr_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
      # CSR format indices should be in ascending order per row
      indices_list = [2, 1, 1]
      indptr_list = [0, 2, 2, 3]
      a = mx.nd.sparse.csr_matrix(
          (data_list, indices_list, indptr_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
      # CSR format indptr should end with value equal with size of indices
      indices_list = [1, 2, 1]
      indptr_list = [0, 2, 2, 4]
      a = mx.nd.sparse.csr_matrix(
          (data_list, indices_list, indptr_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
      # CSR format indices should not be negative
      indices_list = [0, 2, 1]
      indptr_list = [0, -2, 2, 3]
      a = mx.nd.sparse.csr_matrix(
          (data_list, indices_list, indptr_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
      # CSR format should be 2 Dimensional.
      a = mx.nd.array([1, 2, 3])
      assertRaises(ValueError, a.tostype, "csr")
      a = mx.nd.array([[[1, 2, 3]]])
      assertRaises(ValueError, a.tostype, "csr")
      # Row Sparse format indices should be less than the number of rows
      shape = (3, 2)
      data_list = [[1, 2], [3, 4]]
      indices_list = [1, 4]
      a = mx.nd.sparse.row_sparse_array(
          (data_list, indices_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
      # Row Sparse format indices should be in ascending order
      indices_list = [1, 0]
      a = mx.nd.sparse.row_sparse_array(
          (data_list, indices_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
      # Row Sparse format indices should not be negative
      indices_list = [1, -2]
      a = mx.nd.sparse.row_sparse_array(
          (data_list, indices_list), shape=shape
      )
      assertRaises(mx.base.MXNetError, a.check_format)
  
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 37 for calling a global function with example usage: test_sparse_nd_check_format() without return types