code: def testSparseSum(self):
      def _sparse(i):
          return sparse_tensor.SparseTensorValue(
              indices=np.array([[0, 0]]),
              values=(i * np.array([1], dtype=np.int64)),
              dense_shape=np.array([1, 1]),
          )
  
      reducer = grouping.Reducer(
          init_func=lambda _: _sparse(np.int64(0)),
          reduce_func=lambda x, y: _sparse(x.values[0] + y.values[0]),
          finalize_func=lambda x: x.values[0],
      )
      for i in range(1, 11):
          dataset = (
              dataset_ops.Dataset.range(2 * i)
              .map(_sparse)
              .apply(
                  grouping.group_by_reducer(
                      lambda x: x.values[0] % 2, reducer
                  )
              )
          )
          self.assertDatasetProduces(
              dataset,
              expected_shapes=tensor_shape.TensorShape([]),
              expected_output=[(i - 1) * i, i * i],
          )
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.experimental.ops import grouping
  from tensorflow.python.data.kernel_tests import checkpoint_test_base
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 4 for calling the GroupByReducerTest obj's underlying member method code with example usage: obj.testSparseSum() and returns: sparse_tensor