human
Complete this python program:
def _protect_original_resources(f):
assistant
#Here is the Python program you requested.

    """Wrapper to ensure that mutated resources are discarded on retries.
    """
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        ctx = request.context
        if ('resources' in ctx):
            orig = ctx.get('protected_resources')
            if (not orig):
                ctx['protected_resources'] = ctx['resources']
            memo = {id(constants.ATTR_NOT_SPECIFIED): constants.ATTR_NOT_SPECIFIED}
            ctx['resources'] = copy.deepcopy(ctx['protected_resources'], memo=memo)
        return f(*args, **kwargs)
    return wrapped