<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def auth_required(validator):
 """Decorate a RequestHandler or method to require that a request is authenticated If decorating a coroutine make sure coroutine decorator is first. eg.:: class Handler(tornado.web.RequestHandler):
 @auth_required(validator) @coroutine def get(self):
 pass :param validator: a coroutine that will validate the token and return True/False """

    def _auth_required_decorator(handler):
        if inspect.isclass(handler):
            return _wrap_class(handler, validator)
        return _auth_required(handler, validator)

    return _auth_required_decorator