code: def testCriticalSectionWithControlFlow(self, outer_cond, inner_cond):
      if (
          not context.executing_eagerly()
          and control_flow_v2_toggles.control_flow_v2_enabled()
      ):
          self.skipTest("b/135070612")
      cs = critical_section_ops.CriticalSection(shared_name="cs")
      v = resource_variable_ops.ResourceVariable(0.0, name="v")
      num_concurrent = 100
  
      # pylint: disable=cell-var-from-loop
      def fn(a, b):
          c = v.read_value()
  
          def true_fn():
              with ops.control_dependencies([c]):
                  nv = v.assign_add(a * b)
                  with ops.control_dependencies([nv]):
                      return array_ops.identity(c)
  
          return cond.cond(
              array_ops.identity(inner_cond), true_fn, lambda: c
          )
  
      def execute():
          return cs.execute(lambda: fn(1.0, 2.0))
  
      r = [
          cond.cond(
              array_ops.identity(outer_cond), execute, v.read_value
          )
          for _ in range(num_concurrent)
      ]
      # pylint: enable=cell-var-from-loop
  
      self.evaluate(v.initializer)
      r_value = self.evaluate(r)
      if inner_cond and outer_cond:
          self.assertAllClose(
              [2.0 * i for i in range(num_concurrent)], sorted(r_value)
          )
      else:
          self.assertAllClose([0] * num_concurrent, r_value)
  
imports: import itertools
  from absl.testing import parameterized
  from tensorflow.python.data.experimental.ops import prefetching_ops
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import ops
  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 control_flow_assert
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import control_flow_v2_toggles
  from tensorflow.python.ops import critical_section_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import while_loop
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 2 for calling the CriticalSectionTest obj's underlying member method code with example usage: obj.testCriticalSectionWithControlFlow(outer_cond, inner_cond) and returns: cond, cs, array_ops