code: def _assert_no_instances(cls, when=""):
      __tracebackhide__ = True
      n = 0
      ref = list()
      gc.collect()
      objs = gc.get_objects()
      for obj in objs:
          try:
              check = isinstance(obj, cls)
          except Exception:  # such as a weakref
              check = False
          if check:
              if cls.__name__ == "Brain":
                  ref.append(
                      f'Brain._cleaned = {getattr(obj, "_cleaned", None)}'
                  )
              rr = gc.get_referrers(obj)
              count = 0
              for r in rr:
                  if (
                      r is not objs
                      and r is not globals()
                      and r is not locals()
                      and not inspect.isframe(r)
                  ):
                      if isinstance(r, (list, dict, tuple)):
                          rep = f"len={len(r)}"
                          r_ = gc.get_referrers(r)
                          types = (_fullname(x) for x in r_)
                          types = "/".join(
                              sorted(
                                  set(x for x in types if x is not None)
                              )
                          )
                          rep += f", {len(r_)} referrers: {types}"
                          del r_
                      else:
                          rep = repr(r)[:100].replace("\n", " ")
                          # If it's a __closure__, get more information
                          if rep.startswith("<cell at "):
                              try:
                                  rep += f" ({repr(r.cell_contents)[:100]})"
                              except Exception:
                                  pass
                      name = _fullname(r)
                      ref.append(f"{name}: {rep}")
                      count += 1
                  del r
              del rr
              n += count > 0
          del obj
      del objs
      gc.collect()
      assert n == 0, f"\n{n} {cls.__name__} @ {when}:\n" + "\n".join(
          ref
      )
  
imports: import fnmatch
  import gc
  import hashlib
  import inspect
  import os
  import subprocess
  import sys
  import traceback
  import weakref
  from contextlib import ExitStack, contextmanager
  from importlib.resources import files
  from math import log
  from queue import Empty, Queue
  from string import Formatter
  from textwrap import dedent
  from threading import Thread
  import numpy
  from decorator import FunctionMaker
  from ._logging import logger, verbose, warn
  from .check import _check_option, _validate_type
label_desc: Use image node_id 14 for calling a global function with example usage: _assert_no_instances(cls, when) without return types