@contextmanager<EOL>def gc_state(state):
orig_state = gc.isenabled()<EOL>set_gc_state(state)<EOL>yield<EOL>set_gc_state(orig_state)<EOL>
Context manager to set state of garbage collector to `state`

    Parameters
    ----------
    state : bool
        True for gc enabled, False for disabled

    Examples
    --------
    >>> with gc_state(False):
    ...     assert not gc.isenabled()
    >>> with gc_state(True):
    ...     assert gc.isenabled()