<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def restore_gc_state():
 """ Restore the garbage collector state on leaving the with block. """

    old_isenabled = gc.isenabled()
    old_flags = gc.get_debug()
    try:
        yield
    finally:
        gc.set_debug(old_flags)
        (gc.enable if old_isenabled else gc.disable)()