code: def test_lengths_mean(self, inputs, gc, dc):
      X, Y = inputs
      op = core.CreateOperator("LengthsMean", ["X", "Y"], "out")
  
      def ref(D, L):
          R = np.zeros(shape=(L.size,) + D.shape[1:], dtype=D.dtype)
          line = 0
          for g in range(L.size):
              for _ in range(L[g]):
                  if len(D.shape) > 1:
                      R[g, :] += D[line, :]
                  else:
                      R[g] += D[line]
                  line += 1
              if L[g] > 1:
                  if len(D.shape) > 1:
                      R[g, :] = R[g, :] / L[g]
                  else:
                      R[g] = R[g] / L[g]
  
          return [R]
  
      self.assertReferenceChecks(gc, op, [X, Y], ref)
      self.assertDeviceChecks(dc, op, [X, Y], [0])
      self.assertGradientChecks(gc, op, [X, Y], 0, [0])
  
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 14 for calling the TestSegmentOps obj's underlying member method code with example usage: obj.test_lengths_mean(inputs, gc, dc) and returns: list