code: def normalize_metrics_summary(
      metrics_summary: Dict[str, Any],
      split: str,
      object_detection_loss_keys: List[str],
  ):
      """Normalizes the metrics in the given metrics summary.
  
      Note that currently we only support metrics of the form 1/N sum f(x_i).
  
      Args:
        metrics_summary: Each value is a sum of a calculated metric over all
          examples.
        split: Split for which we normalize the metrics. Used for logging.
        object_detection_loss_keys: A loss key used for computing the object
          detection loss.
  
      Returns:
        Normalized metrics summary.
  
      Raises:
        TrainingDivergedError: Due to observing a NaN in the metrics.
      """
      for key, val in metrics_summary.items():
          metrics_summary[key] = val[0] / val[1]
          if np.isnan(metrics_summary[key]):
              raise train_utils.TrainingDivergedError(
                  "NaN detected in {}".format(f"{split}_{key}")
              )
  
      # Compute and add object_detection_loss using globally normalize terms:
      object_detection_loss = 0
      for loss_term_key in object_detection_loss_keys:
          object_detection_loss += metrics_summary[loss_term_key]
      metrics_summary["object_detection_loss"] = object_detection_loss
  
      return metrics_summary
  
imports: from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union
  from absl import logging
  from clu import preprocess_spec
  from flax import core
  import jax
  import jax.numpy
  import numpy
  from scenic.train_lib import train_utils
  import scipy
label_desc: Use image node_id 12 for calling a global function with example usage: normalize_metrics_summary(metrics_summary, split, object_detection_loss_keys) and returns: metrics_summary