class_docstr: Python memory leak detection class.
class_docstr_tok: ["Python","memory","leak","detection","class","."]
docstr: Assert no new Python objects.
docstr_tok: ["Assert","no","new","Python","objects","."]
code: def assert_no_new_objects(self, threshold=None):
      """Assert no new Python objects."""
  
      if not threshold:
          threshold = {}
  
      count_diff = self._snapshot_diff(0, -1)
      original_count_diff = copy.deepcopy(count_diff)
      count_diff.subtract(collections.Counter(threshold))
  
      if max(count_diff.values() or [0]) > 0:
          raise AssertionError(
              "New Python objects created exceeded the threshold."
              "\nPython object threshold:\n"
              f"{threshold}\n\nNew Python objects:\n"
              f"{original_count_diff.most_common()}"
          )
      elif min(count_diff.values(), default=0) < 0:
          logging.warning(
              "New Python objects created were less than the threshold."
              "\nPython object threshold:\n"
              f"{threshold}\n\nNew Python objects:\n"
              f"{original_count_diff.most_common()}"
          )
  
file_path: tensorflow/tensorflow/python/framework/python_memory_checker.py
imports: import collections
  import copy
  import gc
  from tensorflow.python.framework import _python_memory_checker_helper
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.profiler import trace
label_desc: Use image node_id 5 for calling the _PythonMemoryChecker obj's underlying member method code with example usage: obj.assert_no_new_objects(threshold) without return types