code: def test_dot_real(data_dict):
      def get_iter(path, data_shape, batch_size):
          data_train = mx.io.LibSVMIter(
              data_libsvm=path,
              data_shape=data_shape,
              batch_size=batch_size,
          )
          data_iter = iter(data_train)
          return data_iter
  
      data_dir = os.path.join(os.getcwd(), "data")
  
      path = os.path.join(data_dir, data_dict["data_name"])
      if not os.path.exists(path):
          get_bz2_data(
              data_dir,
              data_dict["data_name"],
              data_dict["url"],
              data_dict["data_origin_name"],
          )
          assert os.path.exists(path)
  
      k = data_dict["feature_dim"]
      m = data_dict["m"]
      density = estimate_density(path, data_dict["feature_dim"])
  
      mini_path = os.path.join(data_dir, data_dict["data_mini"])
      if not os.path.exists(mini_path):
          os.system(f"head -n 2000 {repr(path)} > {repr(mini_path)}")
          assert os.path.exists(mini_path)
  
      print(
          f"Running Benchmarking on {repr(data_dict['data_mini'])} data"
      )
      for batch_size in data_dict[
          "batch_size"
      ]:  # iterator through different batch size of choice
          print(f"batch_size is {batch_size}")
          # model
          data_shape = (k,)
          train_iter = get_iter(mini_path, data_shape, batch_size)
          weight = mx.nd.random.uniform(low=0, high=1, shape=(k, m))
  
          csr_data = []
          dns_data = []
          num_batch = 0
          for batch in train_iter:
              data = train_iter.getdata()
              csr_data.append(data)
              dns_data.append(data.tostype("default"))
              num_batch += 1
          bag_of_data = [csr_data, dns_data]
          num_repeat = 5
          costs = []
          for d in bag_of_data:
              weight.wait_to_read()
              cost = 0.0
              count = 0
              for d_batch in d:
                  d_batch.wait_to_read()
                  cost += measure_cost(
                      num_repeat, mx.nd.dot, d_batch, weight
                  )
                  count += 1
              costs.append(cost / count)
          t_sparse = costs[0]
          t_dense = costs[1]
          ratio = t_dense / t_sparse
          print(
              "density(%)\tn\tm\tk\tt_dense/t_sparse\tt_dense\tt_sparse"
          )
          fmt = "{:0.4f}\t\t{}\t{}\t{}\t{:0.2f}\t\t\t{:0.4f}\t{:0.6f}"
          print(
              fmt.format(
                  density * 100,
                  batch_size,
                  m,
                  k,
                  ratio,
                  t_dense,
                  t_sparse,
              )
          )
  
file_path: mxnet/benchmark/python/sparse/sparse_op.py
imports: from __future__ import print_function
  import ctypes
  from mxnet.test_utils import *
  import scipy.sparse
  import os
  import time
  import argparse
  from mxnet.base import check_call, _LIB
  from mxnet.test_utils import get_bz2_data
  from util import estimate_density
label_desc: Use image node_id 2 for calling a global function with example usage: test_dot_real(data_dict) and returns: data_iter