code: def test_legacy_sparse_and_lengths_sum_gradient(self, gc, dc):
      X = np.random.rand(3, 64).astype(np.float32)
      Y = np.asarray([20, 20, 10]).astype(np.int32)
      workspace.FeedBlob("X", X)
      workspace.FeedBlob("Y", Y)
      test_net = core.Net("test_net")
      test_net.SparseLengthsSumGradient(["X", "Y"], "out1")
      test_net.LengthsSumGradient(["X", "Y"], "out2")
      workspace.RunNetOnce(test_net)
      out1 = workspace.FetchBlob("out1")
      out2 = workspace.FetchBlob("out2")
      self.assertTrue((out1 == out2).all())
  
imports: from functools import partial
  from hypothesis import given, settings
  import numpy
  import unittest
  import hypothesis.strategies
  from caffe2.python import core, workspace
  import caffe2.python.hypothesis_test_util
  import caffe2.python.serialized_test.serialized_test_util
label_desc: Use image node_id 19 for calling the TestSegmentOps obj's underlying member method code with example usage: obj.test_legacy_sparse_and_lengths_sum_gradient(gc, dc) without return types