code: def _simple_reduce_metrics(
      reducer: Reducer,
      metrics: np.ndarray,
      num_batches: Optional[List[int]] = None,
  ) -> np.float64:
      if reducer == Reducer.AVG:
          if num_batches:
              if len(metrics) != len(num_batches):
                  raise RuntimeError(
                      "Lengths of metrics and num_batches are not equal: "
                      f"{len(metrics)} != {len(num_batches)}."
                  )
          return np.average(metrics, weights=num_batches)  # type: ignore
      elif reducer == Reducer.SUM:
          return np.sum(metrics)  # type: ignore
      elif reducer == Reducer.MAX:
          return np.max(metrics)  # type: ignore
      elif reducer == Reducer.MIN:
          return np.min(metrics)  # type: ignore
      else:
          raise NotImplementedError
  
imports: import abc
  import enum
  import itertools
  from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, overload
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _simple_reduce_metrics(reducer, metrics, num_batches) and returns: np, np, np, np