code: def test_sparse_lengths_positional_weighted_sum(self, gc, dc):
      D = np.random.rand(50, 3, 4, 5).astype(np.float32)
      W = np.random.rand(50).astype(np.float32)
      indices = np.random.randint(0, 50, size=10).astype(np.int64)
      L = np.asarray([4, 4, 2]).astype(np.int32)
      op = core.CreateOperator(
          "SparseLengthsPositionalWeightedSum",
          ["D", "W", "indices", "L"],
          "out",
      )
  
      def ref_sparse(D, W, indices, L):
          workspace.FeedBlob("L", L)
          lengths_range_fill_op = core.CreateOperator(
              "LengthsRangeFill", ["L"], ["L_pos_seq"]
          )
          workspace.RunOperatorOnce(lengths_range_fill_op)
  
          workspace.FeedBlob("W", W)
          gather_op = core.CreateOperator(
              "Gather", ["W", "L_pos_seq"], ["W_gathered"]
          )
          workspace.RunOperatorOnce(gather_op)
  
          workspace.FeedBlob("D", D)
          workspace.FeedBlob("indices", indices)
          sparse_op = core.CreateOperator(
              "SparseLengthsWeightedSum",
              ["D", "W_gathered", "indices", "L"],
              "out_ref",
          )
          workspace.RunOperatorOnce(sparse_op)
  
          return (workspace.FetchBlob("out_ref"),)
  
      self.assertReferenceChecks(gc, op, [D, W, indices, L], ref_sparse)
  
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 21 for calling the TestSegmentOps obj's underlying member method code with example usage: obj.test_sparse_lengths_positional_weighted_sum(gc, dc) and returns: workspace