code: def testAccumulatorCancel(self):
      # We need each thread to keep its own device stack or the device scopes
      # won't be properly nested.
      ops.get_default_graph().switch_to_thread_local()
      with self.cached_session() as sess:
          q = data_flow_ops.SparseConditionalAccumulator(
              dtypes_lib.float32,
              name="Q",
              shape=tensor_shape.TensorShape([1, 2, 3]),
          )
          takeg_t = q.take_indexed_slices_grad(1)
  
          takeg_thread = self.checkedThread(
              self._blocking_takeg, args=(sess, takeg_t)
          )
  
          takeg_thread.start()
  
          time.sleep(1.0)
  
          sess.close()  # Will cancel blocked operation
  
          takeg_thread.join()
  
imports: import time
  import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 20 for calling the IndexedSlicesConditionalAccumulatorTest obj's underlying member method code with example usage: obj.testAccumulatorCancel() without return types