code: def _process_combined_metrics_and_batches(
      combined_metrics_and_batches: List[Any],
  ) -> Tuple[Dict[str, Any], List[int]]:
      # Remove entries with 0 num batches. These are from ranks that do not report metrics.
      combined_metrics_and_batches = [
          a for a in combined_metrics_and_batches if a[1]
      ]
  
      # Reshape so e.g. all_metrics = [metrics, metrics, ...].
      all_metrics, all_num_batches = zip(*combined_metrics_and_batches)
  
      # convert all_metrics from List[Dict[str, Any]] to Dict[str, List[Any]].
      keys = all_metrics[0].keys()
      metrics_lists = {
          key: [m[key] for m in all_metrics] for key in keys
      }
  
      return metrics_lists, list(all_num_batches)
  
file_path: determined/harness/determined/pytorch/_metric_utils.py
imports: import logging
  from typing import Any, Dict, List, Optional, Tuple, Union, cast
  import numpy
  import torch
  import determined
  from determined import pytorch, util
label_desc: Use image node_id 1 for calling a global function with example usage: _process_combined_metrics_and_batches(combined_metrics_and_batches) and returns: metrics_lists,  list