def retry_timeout_scale(total_retries: int, remaining: int, scale: float=0.3
    ) ->float:
    """
    Calculate an exponential retry timeout based on the max and remaining number of retries

    :param total_retries: total number of retries allowed
    :param remaining: number of retries remaining
    :param scale: optional scale for exponential, defaults to 0.3
    :return: retry timeout in seconds
    """
    return 2 ** ((total_retries - remaining) * scale)
