human
Complete the below
def check_response(method):

    ''''Decorated functions will run, and if they come back
    with a 429 and retry-after header, will wait and try again.'
    '''
assistant
#Here is the Python program you requested.
    @functools.wraps(method)
    def wrapped(self, *args, **kwargs):
        resp = method(self, *args, **kwargs)
        status = resp.status_code
        if (400 < status):
            if (resp.status_code == 429):
                self.handle_429(resp, *args, **kwargs)
                return method(self, *args, **kwargs).json()
            msg_args = (resp, resp.text, resp.headers)
            msg = ('Bad    api    response:    %r    %r    %r' % msg_args)
            raise BadApiResponse(resp, msg)
        return resp.json()
    return wrapped