<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def denied_response(self, req):
 """Returns a standard WSGI response callable with the status of 403 or 401 depending on whether the REMOTE_USER is set or not. """

        if not hasattr(req, 'credentials_valid'):
            req.credentials_valid = None
        if req.remote_user or req.credentials_valid:
            return HTTPForbidden(request=req)
        else:
            return HTTPUnauthorized(request=req)