code: def make_metrics(
      num_inputs: Optional[int], batch_metrics: List[Dict[str, Any]]
  ) -> Dict[str, Any]:
      """Make metrics dict including aggregates given individual data points."""
      import numpy as np
  
      metric_dict = _list_to_dict(batch_metrics)
      validate_batch_metrics(batch_metrics)
  
      avg_metrics = {}  # type: Dict[str, Optional[float]]
      for name, values in metric_dict.items():
          m = None  # type: Optional[float]
          try:
              np_values = np.array(values)
              filtered_values = np_values[
                  np_values != None
              ]  # noqa: E711
              m = np.mean(filtered_values).item()
          except (TypeError, ValueError):
              # If we get here, values are non-scalars, which cannot be averaged.
              # We keep the key so consumers can see all the metric names but
              # leave the value as None.
              pass
          avg_metrics[name] = m
  
      metrics = {
          "batch_metrics": batch_metrics,
          "avg_metrics": avg_metrics,
      }  # type: Dict[str, Any]
      if num_inputs is not None:
          metrics["num_inputs"] = num_inputs
  
      return metrics
  
imports: import collections
  import contextlib
  import copy
  import datetime
  import enum
  import errno
  import inspect
  import json
  import logging
  import math
  import numbers
  import os
  import pathlib
  import random
  import re
  import shutil
  import signal
  import socket
  import stat
  import subprocess
  import time
  import uuid
  from typing import Any, Callable, Dict, Iterator, List, Optional, Set, SupportsFloat, Tuple, Union, cast
  import psutil
  import determined
  from determined import constants
  from determined.common import check, detignore, util
label_desc: Use image node_id 10 for calling a global function with example usage: make_metrics(num_inputs, batch_metrics) and returns: metrics