<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def release_save(lock):
 """Release a lock and return its state."""

    if hasattr(lock, '_release_save'):
        return lock._release_save()
    elif hasattr(lock, 'release'):
        lock.release()
    else:
        raise TypeError('expecting Lock/RLock')