code: def assert_deallocated(func, *args, **kwargs):
      """Context manager to check that object is deallocated
  
      This is useful for checking that an object can be freed directly by
      reference counting, without requiring gc to break reference cycles.
      GC is disabled inside the context manager.
  
      This check is not available on PyPy.
  
      Parameters
      ----------
      func : callable
          Callable to create object to check
      \\*args : sequence
          positional arguments to `func` in order to create object to check
      \\*\\*kwargs : dict
          keyword arguments to `func` in order to create object to check
  
      Examples
      --------
      >>> class C(object): pass
      >>> with assert_deallocated(C) as c:
      ...     # do something
      ...     del c
  
      >>> class C(object):
      ...     def __init__(self):
      ...         self._circular = self # Make circular reference
      >>> with assert_deallocated(C) as c: #doctest: +IGNORE_EXCEPTION_DETAIL
      ...     # do something
      ...     del c
      Traceback (most recent call last):
          ...
      ReferenceError: Remaining reference(s) to object
      """
      if IS_PYPY:
          raise RuntimeError(
              "assert_deallocated is unavailable on PyPy"
          )
  
      with gc_state(False):
          obj = func(*args, **kwargs)
          ref = weakref.ref(obj)
          yield obj
          del obj
          if ref() is not None:
              raise ReferenceError("Remaining reference(s) to object")
  
file_path: catboost/contrib/python/scipy/py2/scipy/_lib/_gcutils.py
imports: import weakref
  import gc
  import sys
  from contextlib import contextmanager
label_desc: Use image node_id 3 for calling a global function with example usage: assert_deallocated(func) without return types