code: def test_sparse_lengths_mean_rowwise_sparse_with_skipped_pruning(
      self, num_rows, blocksize, seed, empty_indices, engine, bit_rate
  ):
      net = core.Net("bench")
  
      np.random.seed(seed)
  
      input_data = np.random.rand(num_rows, blocksize).astype(
          np.float32
      )
      if empty_indices:
          lengths = np.zeros(num_rows, dtype=np.int32)
          num_indices = 0
      else:
          num_indices = np.random.randint(len(input_data))
          # the number of indices per sample
          lengths_split = np.clip(num_indices // 2, 1, 10)
          lengths = (
              np.ones([num_indices // lengths_split], dtype=np.int32)
              * lengths_split
          )
          # readjust num_indices when lengths_split doesn't divide num_indices
          num_indices = num_indices // lengths_split * lengths_split
      #  Use int32 here because int64 is covered by test_sparse_lengths_sum
      indices = np.random.randint(
          low=0,
          high=len(input_data),
          size=[num_indices],
          dtype=np.int32,
      )
  
      op = core.CreateOperator(
          "FloatToFused" + str(bit_rate) + "BitRowwiseQuantized",
          "input_data",
          "quantized_data",
          engine=engine,
      )
      net.Proto().op.extend([op])
      op = core.CreateOperator(
          "Fused" + str(bit_rate) + "BitRowwiseQuantizedToFloat",
          "quantized_data",
          "dequantized_data",
      )
      net.Proto().op.extend([op])
      op = core.CreateOperator(
          "FloatToFused" + str(bit_rate) + "BitFakeRowwiseQuantized",
          "input_data",
          "fake_quantized_data",
          engine=engine,
      )
      net.Proto().op.extend([op])
  
      net.SparseLengthsMean(
          ["dequantized_data", "indices", "lengths"], "mean_reference"
      )
      net.SparseLengthsMeanFused8BitRowwise(
          ["fake_quantized_data", "indices", "lengths"],
          "mean_fake_quantized",
      )
      op1 = core.CreateOperator(
          "SparseLengthsMeanFused" + str(bit_rate) + "BitRowwise",
          ["quantized_data", "indices", "lengths"],
          "mean_quantized",
      )
      op2 = core.CreateOperator(
          "SparseLengthsMean" + str(bit_rate) + "BitRowwiseSparse",
          ["quantized_data", "indices", "lengths"] + ["mapping_table"],
          "mean_quantized_pruned",
      )
      net.Proto().op.extend([op1, op2])
      net.Proto().external_input.extend(["input_data", "mapping_table"])
  
      workspace.FeedBlob("input_data", input_data)
      workspace.FeedBlob("indices", indices)
      workspace.FeedBlob("lengths", lengths)
      mapping_table = np.array([0]).astype(dtype=np.int32)
      workspace.FeedBlob("mapping_table", mapping_table)
  
      workspace.GlobalInit(["caffe2", "--caffe2_log_level=0"])
      workspace.RunNetOnce(net)
  
      mean_reference = workspace.FetchBlob("mean_reference")
      mean_fake_quantized = workspace.FetchBlob("mean_fake_quantized")
      mean_quantized = workspace.FetchBlob("mean_quantized")
      mean_quantized_pruned = workspace.FetchBlob(
          "mean_quantized_pruned"
      )
  
      np.testing.assert_array_almost_equal(
          mean_reference, mean_quantized
      )
      np.testing.assert_array_equal(mean_fake_quantized, mean_quantized)
      np.testing.assert_array_equal(
          mean_quantized_pruned, mean_quantized
      )
  
file_path: pytorch/caffe2/python/operator_test/lengths_reducer_fused_nbit_rowwise_ops_test.py
imports: import caffe2.python.hypothesis_test_util
  import hypothesis.strategies
  import numpy
  from caffe2.python import core, workspace
  from hypothesis import given
label_desc: Use image node_id 4 for calling the TestLengthsReducerOpsFusedNBitRowwise obj's underlying member method code with example usage: obj.test_sparse_lengths_mean_rowwise_sparse_with_skipped_pruning(num_rows, blocksize, seed, empty_indices, engine, bit_rate) without return types