code: def gc_tester():
      """Tests that an object is garbage collected.
  
      Assumes that any unreferenced objects are fully collected after calling
      `gc.collect()`.  That is true on CPython, but does not appear to reliably
      hold on PyPy.
      """
  
      weak_refs = []
  
      def add_ref(obj):
          # PyPy does not support `gc.is_tracked`.
          if hasattr(gc, "is_tracked"):
              assert gc.is_tracked(obj)
          weak_refs.append(weakref.ref(obj))
  
      yield add_ref
  
      gc.collect()
      for ref in weak_refs:
          assert ref() is None
  
file_path: coremltools/deps/pybind11/tests/test_custom_type_setup.py
imports: import gc
  import weakref
  import pytest
  import env
  from pybind11_tests import custom_type_setup
label_desc: Use image node_id 1 for calling a global function with example usage: gc_tester() without return types