code: def automatic_control_dependencies(f):
      """Wraps f to automatically insert control dependencies.
  
      The inserted dependencies ensure that:
        1. All stateful ops in f run when the result of f runs
        2. Updates to the same resources happen in order.
  
      Args:
        f: the function to be wrapped.
  
      Returns:
        The wrapped function.
      """
  
      def wrapper(*args, **kwargs):
          with AutomaticControlDependencies() as a:
              result = f(*args, **kwargs)
              result_flat = [
                  a.mark_as_return(t) for t in nest.flatten(result)
              ]
              return nest.pack_sequence_as(result, result_flat)
  
      return tf_decorator.make_decorator(f, wrapper)
  
imports: import collections
  import enum
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.framework import auto_control_deps_utils
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import op_def_registry
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import registry
  from tensorflow.python.framework import sparse_tensor
  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 tensor_array_ops
  from tensorflow.python.util import nest
  from tensorflow.python.util import object_identity
  from tensorflow.python.util import tf_decorator
label_desc: Use image node_id 6 for calling a global function with example usage: automatic_control_dependencies(f) and returns: tf_decorator, nest