parameters: (f)
return_statement: return tf_decorator.make_decorator(f, wrapper)
docstring: 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.
docstring_summary: Wraps f to automatically insert control dependencies.
docstring_tokens: Wraps f to automatically insert control dependencies .
function: 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)
function_tokens: def automatic_control_dependencies ( f ) : 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 )