<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_response(response, body):
 """ Return an instance of a ClientException or subclass based on an httplib2 response. Usage:: if resp.status_code != 200: raise exception_from_response(resp, body) """

    if isinstance(response, dict):
        status = response.get("status_code")
    else:
        status = response.status_code
    cls = _code_map.get(int(status), ClientException)

#    import pyrax
#    pyrax.utils.trace()

    request_id = response.headers.get("x-compute-request-id")
    if body:
        message = "n/a"
        details = "n/a"
        if isinstance(body, dict):
            message = body.get("message")
            details = body.get("details")
            if message is details is None:
                error = body[next(iter(body))]
                if isinstance(error, dict):
                    message = error.get("message", None)
                    details = error.get("details", None)
                else:
                    message = error
                    details = None
        else:
            message = body
        return cls(code=status, message=message, details=details,
                   request_id=request_id)
    else:
        return cls(code=status, request_id=request_id)