class_docstr: Memory leak detection class.
  
  This is a utility class to detect Python and C++ memory leaks. It's intended
  for both testing and debugging. Basic usage:
  
  >>> # MemoryChecker() context manager tracks memory status inside its scope.
  >>> with MemoryChecker() as memory_checker:
  >>>   tensors = []
  >>>   for _ in range(10):
  >>>     # Simulating `tf.constant(1)` object leak every iteration.
  >>>     tensors.append(tf.constant(1))
  >>>
  >>>     # Take a memory snapshot for later analysis.
  >>>     memory_checker.record_snapshot()
  >>>
  >>> # `report()` generates a html graph file showing allocations over
  >>> # snapshots per every stack trace.
  >>> memory_checker.report()
  >>>
  >>> # This assertion will detect `tf.constant(1)` object leak.
  >>> memory_checker.assert_no_leak_if_all_possibly_except_one()
  
  `record_snapshot()` must be called once every iteration at the same location.
  This is because the detection algorithm relies on the assumption that if there
  is a leak, it's happening similarly on every snapshot.
docstr: Raises an exception if a leak is detected.
  
  This algorithm classifies a series of allocations as a leak if it's the same
  type(Python) or it happens at the same stack trace(C++) at every snapshot,
  but possibly except one snapshot.
code: def assert_no_leak_if_all_possibly_except_one(self):
      """Raises an exception if a leak is detected.
  
      This algorithm classifies a series of allocations as a leak if it's the same
      type(Python) or it happens at the same stack trace(C++) at every snapshot,
      but possibly except one snapshot.
      """
  
      self._python_memory_checker.assert_no_leak_if_all_possibly_except_one()
      if CppMemoryChecker:
          self._cpp_memory_checker.assert_no_leak_if_all_possibly_except_one()
  
file_path: tensorflow/tensorflow/python/framework/memory_checker.py
imports: from tensorflow.python.framework.python_memory_checker import _PythonMemoryChecker
  from tensorflow.python.profiler import trace
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 5 for calling the MemoryChecker obj's underlying member method code with example usage: obj.assert_no_leak_if_all_possibly_except_one() without return types