code: def testMultipleCSExecutionsRequestSameResource(self):
      cs0 = critical_section_ops.CriticalSection()
      cs1 = critical_section_ops.CriticalSection()
      v = resource_variable_ops.ResourceVariable(0.0, name="v")
      cs0.execute(lambda: v + 1)
      # It's OK for the same CriticalSection to access this resource.
      cs0.execute(lambda: v - 1)
      # It's *not* OK for a different CriticalSection to access it by
      # default.
      with self.assertRaisesRegex(
          ValueError, "requested exclusive resource access"
      ):
          cs1.execute(lambda: v + 1)
      # It's not even OK if the second call doesn't request exclusive access.
      with self.assertRaisesRegex(
          ValueError, "requested exclusive resource access"
      ):
          cs1.execute(lambda: v + 1, exclusive_resource_access=False)
  
      v2 = resource_variable_ops.ResourceVariable(0.0, name="v2")
      cs0.execute(lambda: v2 + 1, exclusive_resource_access=False)
      # It's OK if neither requests exclusive resource access.
      cs1.execute(lambda: v2 + 1, exclusive_resource_access=False)
  
      # It's not OK if the second request requires exclusive resource
      # access.
      with self.assertRaisesRegex(
          ValueError, "requested exclusive resource access"
      ):
          cs1.execute(lambda: v2 + 1)
  
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 10 for calling the CriticalSectionTest obj's underlying member method code with example usage: obj.testMultipleCSExecutionsRequestSameResource() without return types