code: def get_latest_metrics_dict(
      progress_tracker_metrics: Dict[
          str, Dict[str, List[TrainerMetric]]
      ]
  ) -> Dict[str, Dict[str, float]]:
      """Returns a dict of field name -> metric name -> latest metric value."""
      latest_metrics_dict = defaultdict(dict)
      for (
          feature_name,
          metrics_dict,
      ) in progress_tracker_metrics.items():
          for metric_name, metrics in metrics_dict.items():
              if metrics:
                  # Metrics may be missing if computing metrics was excepted, if the metrics are entirely empty
                  # due to a missing subset, or if evaluate_training_set is False.
                  latest_metrics_dict[feature_name][
                      metric_name
                  ] = metrics[-1][-1]
      return latest_metrics_dict
  
imports: import logging
  from collections import defaultdict
  from typing import Dict, List, Tuple, TYPE_CHECKING
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import AUTO, COMBINED, LOSS
  from ludwig.models.base import BaseModel
  from ludwig.modules.metric_modules import get_best_function
  from ludwig.utils.data_utils import save_json
  from ludwig.utils.metric_utils import TrainerMetric
label_desc: Use image node_id 2 for calling a global function with example usage: get_latest_metrics_dict(progress_tracker_metrics) and returns: latest_metrics_dict