code: def normalize_metrics_summary(
      metrics_summary, split, object_detection_loss_keys
  ):
      """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: dict; Each value is a sum of a calculated metric over all
          examples.
        split: str; Split for which we normalize the metrics. Used for logging.
        object_detection_loss_keys: list; 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: import copy
  import json
  import os
  from typing import Any, Dict, Optional, Set
  from absl import logging
  from flax import core
  from flax import optim
  from flax import traverse_util
  import jax
  from jax.example_libraries import optimizers
  import jax.numpy
  import numpy
  import PIL
  import PIL.ImageDraw
  import PIL.ImageFont
  from scenic.common_lib import image_utils
  from scenic.dataset_lib.coco_dataset import coco_eval
  from scenic.model_lib.base_models import box_utils
  from scenic.train_lib_deprecated import optimizers
  from scenic.train_lib_deprecated import train_utils
  import scipy.special
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: normalize_metrics_summary(metrics_summary, split, object_detection_loss_keys) and returns: metrics_summary