def calculate_run_metrics(accuracies):
    """Calculates average accuracy, forgetting, and learning accuracy given accuracies on each task
    for model after every task.
    """
    average_accuracy = 0
    forgetting = 0
    learning_accuracy = 0
    for task_id in accuracies:
        average_accuracy += accuracies[task_id][-1]
        forgetting += max(accuracies[task_id]) - accuracies[task_id][-1]
        learning_accuracy += accuracies[task_id][0]
    return (
        average_accuracy / len(accuracies),
        forgetting / len(accuracies),
        learning_accuracy / len(accuracies),
    )