def METHOD_NAME(
    dict_dict_trainer_metrics: Dict[str, Dict[str, List[TrainerMetric]]]
) -> Dict[str, Dict[str, List[float]]]:
    """Reduces Dict[feature_name, Dict[metric_name, List[TrainerMetric]]] to Dict[feature_name, Dict[metric_name,
    List[float]]].
    Used for flattening the results returned by trainer.py::train(), which come from ProgressTracker.
    """
    flattened_dict = defaultdict(lambda: defaultdict(list))
    for feature_name, trainer_metric_dict in dict_dict_trainer_metrics.items():
        for metric_name, trainer_metrics in trainer_metric_dict.items():
            for trainer_metric in trainer_metrics:
                flattened_dict[feature_name][metric_name].append(trainer_metric[-1])
    # Convert defaultdict to dict so JSON serialization works with dataclasses.asdict().
    return {k: dict(v) for k, v in flattened_dict.items()}