code: def testCancellation(self):
      ds = dataset_ops.Dataset.from_tensors(1).repeat()
      result = ds.reduce(0, lambda x, y: x + y)
      with self.cached_session() as sess:
          # The `result` op is guaranteed to not complete before cancelled because
          # the dataset that is being reduced is infinite.
          thread = self.checkedThread(
              self.assert_op_cancelled, args=(result,)
          )
          thread.start()
          time.sleep(0.2)
          sess.close()
          thread.join()
  
imports: import time
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.experimental.ops import testing
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.eager import def_function
  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 ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 12 for calling the ReduceTest obj's underlying member method code with example usage: obj.testCancellation() without return types