code: def test_sparse_reshape_mm(self):
      M, N, K = 300, 400, 500
      A = np.random.rand(M, K).astype(np.float32)
      A_sparse = A * (np.random.rand(*A.shape) > 0.5)
      A_sparse = A_sparse.reshape((K, M))
      A_coo = coo_matrix(A_sparse)
      idx0, idx1, a = A_coo.row, A_coo.col, A_coo.data
      B = np.random.rand(K, N).astype(np.float32)
  
      workspace.FeedBlob("col", idx1.astype(np.int64))
      workspace.FeedBlob("row", idx0.astype(np.int32))
      workspace.FeedBlob("B", B)
      workspace.FeedBlob("a", a)
  
      reshape_op = core.CreateOperator(
          "SparseMatrixReshape",
          ["col", "row"],
          ["new_col", "new_row"],
          old_shape=(K, M),
          new_shape=(M, K),
      )
  
      mm_op = core.CreateOperator(
          "SparseUnsortedSegmentWeightedSum",
          ["B", "a", "new_col", "new_row"],
          ["Y"],
      )
  
      workspace.RunOperatorOnce(reshape_op)
      workspace.RunOperatorOnce(mm_op)
  
      Y = workspace.FetchBlob("Y")
      np.testing.assert_allclose(
          A_sparse.reshape(M, K).dot(B), Y, rtol=1e-4
      )
  
file_path: pytorch/caffe2/experiments/python/sparse_reshape_op_test.py
imports: import numpy
  from scipy.sparse import coo_matrix
  from caffe2.python import core, workspace
  from caffe2.python.test_util import TestCase
label_desc: Use image node_id 4 for calling the TestSparseMatrixReshapeOp obj's underlying member method code with example usage: obj.test_sparse_reshape_mm() without return types