code: def reduce_trainer_metrics_dict(
      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()}
  
file_path: ludwig/ludwig/utils/metric_utils.py
imports: from collections import defaultdict, namedtuple
  from typing import Dict, List, Optional
  import torch
  from torch import Tensor
  from torchmetrics.metric import Metric
  from ludwig.constants import COMBINED, LOSS, NAME, TYPE
  from ludwig.modules.metric_registry import get_metric_names_for_type
  from ludwig.types import FeatureConfigDict
label_desc: Use image node_id 5 for calling a global function with example usage: reduce_trainer_metrics_dict(dict_dict_trainer_metrics) and returns: unknown