r"""Provides a way for each connection wrapper to handle error
        responses.

        Parameters:
          response(Response): An instance of :class:`.requests.Response`.
          retries(int): The number of times :meth:`.request` has been
            called so far.
          \**kwargs: The parameters with which :meth:`.request` was
            called.  The `retries` parameter is excluded from `kwargs`
            intentionally.

        Returns:
          requests.Response

def _handle_response_error(self, response, retries, **kwargs):
        r"""Provides a way for each connection wrapper to handle error
        responses.

        Parameters:
          response(Response): An instance of :class:`.requests.Response`.
          retries(int): The number of times :meth:`.request` has been
            called so far.
          \**kwargs: The parameters with which :meth:`.request` was
            called.  The `retries` parameter is excluded from `kwargs`
            intentionally.

        Returns:
          requests.Response
        """
        error = self._convert_response_to_error(response)
        if error is None:
            return response

        max_retries = self._max_retries_for_error(error)
        if max_retries is None or retries >= max_retries:
            return response

        backoff = min(0.0625 * 2 ** retries, 1.0)
        self.logger.warning("Sleeping for %r before retrying failed request...", backoff)
        time.sleep(backoff)

        retries += 1
        self.logger.warning("Retrying failed request. Attempt %d/%d.", retries, max_retries)

        return self.request(retries=retries, **kwargs)