class_docstr: Context manager to automatically add control dependencies.
  
  Code under this context manager will act as if a sensible set of control
  dependencies were present. More specifically:
    1. All stateful ops in the scope will execute (with the exception of ops in
       ASYNC_STATEFUL_OPS and LEGACY_RANDOM_OPS)
    2. Stateful ops which modify the same resource will execute in program order
  
  Note: creating variables in an automatic control dependencies context is not
  supported (the value of the variables will never change as they will keep
  getting reinitialized).
  
  NOT THREAD SAFE
class_docstr_tok: ["Context","manager","to","automatically","add","control","dependencies",".","Code","under","this","context","manager","will","act","as","if","a","sensible","set","of","control","dependencies","were","present",".","More","specifically",":","1",".","All","stateful","ops","in","the","scope","will","execute","(","with","the","exception","of","ops","in","ASYNC_STATEFUL_OPS","and","LEGACY_RANDOM_OPS",")","2",".","Stateful","ops","which","modify","the","same","resource","will","execute","in","program","order","Note",":","creating","variables","in","an","automatic","control","dependencies","context","is","not","supported","(","the","value","of","the","variables","will","never","change","as","they","will","keep","getting","reinitialized",")",".","NOT","THREAD","SAFE"]
docstr: Acts like identity but marks the `Tensor` as a return value.
  
  This will possibly return a copy of the `Tensor`. Usage:
  
  ```
    with AutomaticControlDependencies() as a:
     ...
     t = a.mark_as_return(t)
    _ = ...(t...)  # i.e. it's safe to use t here
  ```
  
  Args:
    tensor: the `Tensor` to be marked
  
  Returns:
    a copy of the `Tensor`.
docstr_tok: ["Acts","like","identity","but","marks","the","`","Tensor","`","as","a","return","value",".","This","will","possibly","return","a","copy","of","the","`","Tensor","`",".","Usage",":","``","`","with","AutomaticControlDependencies","(",")","as","a",":","...","t","=","a.mark_as_return","(","t",")","_","=","...","(","t","...",")","#","i.e",".","it","'s","safe","to","use","t","here","``","`","Args",":","tensor",":","the","`","Tensor","`","to","be","marked","Returns",":","a","copy","of","the","`","Tensor","`","."]
code: def mark_as_return(self, tensor):
      """Acts like identity but marks the `Tensor` as a return value.
  
      This will possibly return a copy of the `Tensor`. Usage:
  
      ```
        with AutomaticControlDependencies() as a:
         ...
         t = a.mark_as_return(t)
        _ = ...(t...)  # i.e. it's safe to use t here
      ```
  
      Args:
        tensor: the `Tensor` to be marked
  
      Returns:
        a copy of the `Tensor`.
      """
      if isinstance(tensor, indexed_slices.IndexedSlices):
          values = array_ops.identity(tensor.values)
          indices = array_ops.identity(tensor.indices)
          self._returned_tensors.add(indices)
          self._returned_tensors.add(values)
          return indexed_slices.IndexedSlices(
              values, indices, dense_shape=tensor.dense_shape
          )
      elif isinstance(tensor, sparse_tensor.SparseTensor):
          values = array_ops.identity(tensor.values)
          indices = array_ops.identity(tensor.indices)
          self._returned_tensors.add(indices)
          self._returned_tensors.add(values)
          return sparse_tensor.SparseTensor(
              indices, values, dense_shape=tensor.dense_shape
          )
      elif isinstance(tensor, tensor_array_ops.TensorArray):
          flow = array_ops.identity(tensor.flow)
          self._returned_tensors.add(flow)
          return tensor_array_ops.build_ta_with_new_flow(tensor, flow)
      # We want to make the return values depend on the stateful operations, but
      # we don't want to introduce a cycle, so we make the return value the result
      # of a new identity operation that the stateful operations definitely don't
      # depend on.
      tensor = array_ops.identity(tensor)
      self._returned_tensors.add(tensor)
      return tensor
  
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 2 for calling the AutomaticControlDependencies obj's underlying member method code with example usage: obj.mark_as_return(tensor) and returns: tensor, indexed_slices, sparse_tensor, tensor_array_ops