code: def test_create_sparse_nd_from_dense():
      def check_create_from_dns(
          shape, f, dense_arr, dtype, default_dtype, ctx
      ):
          arr = f(dense_arr, dtype=dtype, ctx=ctx)
          assert same(arr.asnumpy(), np.ones(shape))
          assert arr.dtype == dtype
          assert arr.context == ctx
          # verify the default dtype inferred from dense arr
          arr2 = f(dense_arr)
          assert arr2.dtype == default_dtype
          assert arr2.context == mx.context.current_context()
  
      shape = rand_shape_2d()
      dtype = np.int32
      src_dtype = np.float64
      ctx = mx.cpu(1)
      dense_arrs = [
          mx.nd.ones(shape, dtype=src_dtype),
          np.ones(shape, dtype=src_dtype),
          np.ones(shape, dtype=src_dtype).tolist(),
      ]
      for f in [mx.nd.sparse.csr_matrix, mx.nd.sparse.row_sparse_array]:
          for dense_arr in dense_arrs:
              default_dtype = (
                  dense_arr.dtype
                  if isinstance(dense_arr, (NDArray, np.ndarray))
                  else np.float32
              )
              check_create_from_dns(
                  shape, f, dense_arr, dtype, default_dtype, ctx
              )
  
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 31 for calling a global function with example usage: test_create_sparse_nd_from_dense() without return types