class_docstr: A thread-local stack of objects for providing implicit defaults.
class_docstr_tok: ["A","thread-local","stack","of","objects","for","providing","implicit","defaults","."]
docstr: A context manager for manipulating a default stack.
docstr_tok: ["A","context","manager","for","manipulating","a","default","stack","."]
code: def get_controller(self, default: T) -> Iterator[T]:
      """A context manager for manipulating a default stack."""
      self.stack.append(default)
      try:
          yield default
      finally:
          # stack may be empty if reset() was called
          if self.stack:
              if self._enforce_nesting:
                  if self.stack[-1] is not default:
                      raise AssertionError(
                          "Nesting violated for default stack of %s objects"
                          % type(default)
                      )
                  self.stack.pop()
              else:
                  self.stack.remove(default)
  
file_path: tensorflow/tensorflow/python/framework/stack.py
imports: from collections.abc import Iterator
  import threading
  from typing import Generic, Optional, TypeVar
  from tensorflow.python.util import tf_contextlib
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 7 for calling the DefaultStack obj's underlying member method code with example usage: obj.get_controller(default) without return types