code: def test_average_training_metrics() -> None:
      combined_timeseries: Dict[str, Any] = {
          "loss1": [[1, 2], [3, 4]],
          "loss2": [[-1, -2], [-3, -4]],
      }
      combined_num_batches = [2, 2]
      averaged_metrics = metric_utils._average_training_metrics(
          combined_timeseries, combined_num_batches
      )
      expected_metrics: List[Dict[str, Any]] = [
          {"loss1": 2, "loss2": -2},
          {"loss1": 3, "loss2": -3},
      ]
      assert averaged_metrics == expected_metrics
  
      # Test single array metrics
      combined_timeseries = {
          "loss1": [[1, 2], [3, 4]],
          "loss2": [
              [np.array(-1), np.array(-2)],
              [np.array(-3), np.array(-4)],
          ],
      }
      averaged_metrics = metric_utils._average_training_metrics(
          combined_timeseries, combined_num_batches
      )
      expected_metrics = [
          {"loss1": 2, "loss2": np.array(-2)},
          {"loss1": 3, "loss2": np.array(-3)},
      ]
      assert averaged_metrics == expected_metrics
  
file_path: determined/harness/tests/experiment/pytorch/test_metric_utils.py
imports: import logging
  from typing import Any, Dict, List, Tuple, Union
  import numpy
  import pytest
  import torch
  import determined.errors
  import determined.pytorch._metric_utils
  from determined import pytorch
label_desc: Use image node_id 2 for calling a global function with example usage: test_average_training_metrics() without return types