code: def _combine_metrics_across_processes(
      context: det.core.DistributedContext,
      metrics: Dict[str, Any],
      num_batches: int,
  ) -> Tuple[Optional[Dict[str, Any]], Optional[List[int]]]:
      # The chief receives the metric from every other training process.
      assert (
          context.size > 1
      ), "_combine_metrics_across_processes should only be called if context.distributed > 1"
  
      # all_args is a list of [(metrics, num_batches), ...] for each worker.
      all_args = context.gather((metrics, num_batches))
  
      if not context.rank == 0:
          return None, None
  
      # Remove items without keys in dictionary. These are from intermediate model parallel nodes.
      assert all_args is not None, "gathered metrics should not be None"
      return _process_combined_metrics_and_batches(all_args)
  
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 3 for calling a global function with example usage: _combine_metrics_across_processes(context, metrics, num_batches) and returns: _process_combined_metrics_and_batches, None,  None