code: def check_sparse_mathematical_core(
      name,
      stype,
      forward_mxnet_call,
      forward_numpy_call,
      backward_numpy_call=None,
      rhs_arg=None,
      data_init=9.0,
      grad_init=2.0,
      output_grad_stype=None,
      input_grad_stype=None,
      force_overlap=False,
      density=0.5,
      ograd_density=0.5,
      verbose=False,
      shuffle_csr_indices=True,
  ):
      if verbose is True:
          print("TESTING: " + name)
  
      data = mx.symbol.Variable("data", stype=stype)
  
      temp_input_grad_stype = input_grad_stype
  
      if temp_input_grad_stype is None:
          temp_input_grad_stype = stype
  
      if rhs_arg is not None:
          if is_scalar(rhs_arg):
              (
                  expected_result_type,
                  expected_grad_result_type,
              ) = get_fw_bw_result_types_with_scalar(
                  forward_numpy_call,
                  stype,
                  backward_numpy_call,
                  temp_input_grad_stype,
              )
          else:
              (
                  expected_result_type,
                  expected_grad_result_type,
              ) = get_fw_bw_result_types_2(
                  forward_numpy_call,
                  stype,
                  backward_numpy_call,
                  temp_input_grad_stype,
              )
      else:
          (
              expected_result_type,
              expected_grad_result_type,
          ) = get_fw_bw_result_types(
              forward_numpy_call,
              stype,
              backward_numpy_call,
              temp_input_grad_stype,
          )
  
      if (
          input_grad_stype is not None
          and input_grad_stype != expected_grad_result_type
      ):
          print(
              "{}: explicit override of deduced input grad type '{}' with '{}'".format(
                  name, expected_grad_result_type, input_grad_stype
              )
          )
          expected_grad_result_type = input_grad_stype
  
      shape = rand_shape_2d()
  
      if verbose is True:
          print(
              "Shape: ",
              shape,
              "density: ",
              density,
              "force_overlap",
              force_overlap,
          )
  
      if stype == "default":
          data_tmp = np.zeros(shape)
          if abs(density) >= 1e-4:
              data_tmp[:] = data_init
          arr_data = mx.nd.array(data_tmp)
      else:
          arr_data = create_sparse_array_zd(
              shape,
              stype,
              density=density,
              data_init=data_init,
              shuffle_csr_indices=shuffle_csr_indices,
              rsp_indices=gen_rsp_random_indices(
                  shape,
                  density=density,
                  force_indices=[(shape[0] / 2)]
                  if force_overlap is True
                  else None,
              ),
          )
          data_tmp = arr_data.asnumpy()
          if verbose is True:
              print("arr_data indices", arr_data.indices.asnumpy())
  
      if verbose is True:
          print("input", data_tmp)
  
      if backward_numpy_call is None:
          arr_grad = None
      elif expected_grad_result_type == "default":
          if abs(density) < 1e-4:
              arr_grad = mx.nd.zeros(shape)
          else:
              arr_grad = mx.nd.ones(shape)
      else:
          arr_grad = create_sparse_array_zd(
              shape,
              expected_grad_result_type,
              density=density,
              data_init=1,
              shuffle_csr_indices=shuffle_csr_indices,
              rsp_indices=gen_rsp_random_indices(
                  shape,
                  density=density,
                  force_indices=[(shape[0] / 2)]
                  if force_overlap is True
                  else None,
              ),
          )
  
      if rhs_arg is not None:
          test = forward_mxnet_call(data, rhs_arg)
      else:
          test = forward_mxnet_call(data)
  
      args = list()
      args.append(arr_data)
  
      if arr_grad is not None:
          exe_test = test._bind(
              default_device(), args=args, args_grad=[arr_grad]
          )
      else:
          exe_test = test._bind(default_device(), args=args)
  
      exe_test.forward(is_train=True)
      assert exe_test.outputs[0].stype == expected_result_type
      out = exe_test.outputs[0].asnumpy()
  
      if rhs_arg is not None:
          npout = forward_numpy_call(data_tmp, rhs_arg)
      else:
          npout = forward_numpy_call(data_tmp)
  
      if verbose is True:
          print("out", out)
          print("npout", npout)
  
      assert_almost_equal(out, npout, equal_nan=True)
  
      if backward_numpy_call is not None:
          if (
              output_grad_stype == "default"
              or output_grad_stype is None
          ):
              out_grad = mx.nd.empty(shape)
              out_grad[:] = grad_init
          else:
              out_grad = create_sparse_array_zd(
                  shape,
                  output_grad_stype,
                  density=density,
                  data_init=grad_init,
                  shuffle_csr_indices=shuffle_csr_indices,
                  rsp_indices=gen_rsp_random_indices(
                      shape,
                      density=ograd_density,
                      force_indices=[(shape[0] / 2)]
                      if force_overlap is True
                      else None,
                  ),
              )
  
          npout_grad = out_grad.asnumpy()
  
          if verbose is True:
              print("npout_grad", npout_grad)
  
          if rhs_arg is not None:
              temp = backward_numpy_call(data_tmp, rhs_arg)
          else:
              temp = backward_numpy_call(data_tmp)
          input_grad = npout_grad * temp
  
          if verbose is True:
              print(arr_grad.asnumpy())
          exe_test.backward(out_grad)
          if verbose is True:
              print(arr_grad.asnumpy())
  
          assert arr_grad.stype == expected_grad_result_type
  
          if verbose is True:
              print(name)
              print("arr_grad", arr_grad.asnumpy())
              print("input_grad", input_grad)
  
          assert_almost_equal(arr_grad, input_grad, equal_nan=True)
  
imports: from mxnet.test_utils import *
  from mxnet.base import MXNetError
  import pytest
  from common import assertRaises
  import random
  import warnings
label_desc: Use image node_id 15 for calling a global function with example usage: check_sparse_mathematical_core(name, stype, forward_mxnet_call, forward_numpy_call, backward_numpy_call, rhs_arg, data_init, grad_init, output_grad_stype, input_grad_stype, force_overlap, density, ograd_density, verbose, shuffle_csr_indices) without return types