code: def testSideEffect(self):
      a = constant_op.constant(1)
      b = constant_op.constant(1)
      c = math_ops.add(a, b)
      with ops.control_dependencies([c]):
          d = constant_op.constant(42)
      n = math_ops.negative(c)
  
      shared = []
  
      def sub(t):
          shared.append(t)
          return t
  
      c0 = c
      self.assertTrue(c0.op in d.op.control_inputs)
      c = subscribe.subscribe(
          c, lambda t: script_ops.py_func(sub, [t], [t.dtype])
      )
      # Verify that control dependencies are correctly moved to the subscription.
      self.assertFalse(c0.op in d.op.control_inputs)
      self.assertTrue(c.op in d.op.control_inputs)
  
      with self.cached_session() as sess:
          c_out = self.evaluate([c])
          n_out = self.evaluate([n])
          d_out = self.evaluate([d])
  
      self.assertEqual(n_out, [-2])
      self.assertEqual(c_out, [2])
      self.assertEqual(d_out, [42])
      self.assertEqual(shared, [2, 2, 2])
  
imports: import collections
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import subscribe
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 2 for calling the SubscribeTest obj's underlying member method code with example usage: obj.testSideEffect() and returns: t