code: def MaybeCreateControlFlowState(
      between_op_list, between_ops, colocate_gradients_with_ops
  ):
      """Create the state for all the while loops involved in one gradients().
  
      We create a _ControlFlowState when there are while loops involved in
      gradients(). In gradients(), control flow logic is only invoked when
      the _ControlFlowState is not None.
  
      Note that this method modifies `between_op_list` and `between_ops`.
      """
      loop_state = None
      for op in between_op_list:
          if util.IsLoopExit(op):
              if loop_state is None:
                  loop_state = _ControlFlowState()
              if colocate_gradients_with_ops:
                  with ops.colocate_with(op):
                      loop_state.AddWhileContext(
                          op, between_op_list, between_ops
                      )
              else:
                  loop_state.AddWhileContext(
                      op, between_op_list, between_ops
                  )
      return loop_state
  
imports: from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import control_flow_v2_func_graphs
  from tensorflow.python.ops import default_gradient
  from tensorflow.python.ops import gen_data_flow_ops
  from tensorflow.python.ops import gen_resource_variable_ops
  from tensorflow.python.ops import resource_variable_ops
label_desc: Use image node_id 2 for calling a global function with example usage: MaybeCreateControlFlowState(between_op_list, between_ops, colocate_gradients_with_ops) and returns: loop_state