<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stop_patching(name=None):
 # type: (Optional[str]) -> None """ Finish the mocking initiated by `start_patching` Kwargs: name (Optional[str]):
 if given, only unpatch the specified path, else all defined default mocks """

    global _patchers, _mocks
    if not _patchers:
        warnings.warn('stop_patching() called again, already stopped')

    if name is not None:
        items = [(name, _patchers[name])]
    else:
        items = list(_patchers.items())

    for name, patcher in items:
        patcher.stop()
        del _patchers[name]
        del _mocks[name]