code: def test_sparse_to_dense_with_data_to_infer_dim(self):
      op = core.CreateOperator(
          "SparseToDense",
          ["indices", "values", "data_to_infer_dim"],
          ["output"],
      )
      workspace.FeedBlob(
          "indices", np.array([2, 4, 999, 2], dtype=np.int32)
      )
      workspace.FeedBlob(
          "values", np.array([1, 2, 6, 7], dtype=np.int32)
      )
      workspace.FeedBlob(
          "data_to_infer_dim",
          np.array(
              np.zeros(
                  1500,
              ),
              dtype=np.int32,
          ),
      )
  
      workspace.RunOperatorOnce(op)
      output = workspace.FetchBlob("output")
      print(output)
  
      expected = np.zeros(1500, dtype=np.int32)
      expected[2] = 1 + 7
      expected[4] = 2
      expected[999] = 6
  
      self.assertEqual(output.shape, expected.shape)
      np.testing.assert_array_equal(output, expected)
  
file_path: pytorch/caffe2/python/sparse_to_dense_test.py
imports: from caffe2.python import core, workspace
  from caffe2.python.test_util import TestCase
  import numpy
label_desc: Use image node_id 4 for calling the TestSparseToDense obj's underlying member method code with example usage: obj.test_sparse_to_dense_with_data_to_infer_dim() without return types