<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resolve_sid(f):
 """View handler decorator that adds SID resolve and PID validation. - For v1 calls, assume that ``did`` is a pid and raise NotFound exception if it's not valid. - For v2 calls, if DID is a valid PID, return it. If not, try to resolve it as a SID and, if successful, return the new PID. Else, raise NotFound exception. """


    @functools.wraps(f)
    def wrapper(request, did, *args, **kwargs):
        pid = resolve_sid_func(request, did)
        return f(request, pid, *args, **kwargs)

    return wrapper