def calculate_named_averages(
    average_names: dict[str, list],
    category_scores: dict[str, float],
):
    """Calculates the named averages based off the raw category scores.

    For each named average, take a simple average of all the category scores associated with that named average.

    Args:
        average_names (dict[str, list]):  Contains a mapping of named averages to which category scores that average should consist of.
        category_scores (dict[str, float]): Contains the raw scores corresponding to each category.
    """
    average_scores = {}
    for avg_name, category_list in average_names.items():
        composite_subset = {
            category: score
            for category, score in category_scores.items()
            if category in category_list
        }
        if len(composite_subset.values()) > 0:
            average_scores[avg_name] = sum(
                composite_subset.values(),
            ) / len(composite_subset.values())
        else:
            average_scores[avg_name] = 0

    return average_scores
Calculates the named averages based off the raw category scores.

    For each named average, take a simple average of all the category scores associated with that named average.

    Args:
        average_names (dict[str, list]):  Contains a mapping of named averages to which category scores that average should consist of.
        category_scores (dict[str, float]): Contains the raw scores corresponding to each category.
    
llmfoundry/callbacks/eval_gauntlet_callback.py