code: def extract_model_metrics(model):
      """Convert metrics from a Keras model `compile` API to dictionary.
  
      This is used for converting Keras models to Estimators and SavedModels.
  
      Args:
        model: A `tf.keras.Model` object.
  
      Returns:
        Dictionary mapping metric names to metric instances. May return `None` if
        the model does not contain any metrics.
      """
      if getattr(model, "_compile_metrics", None):
          # TODO(psv/kathywu): use this implementation in model to estimator flow.
          # We are not using model.metrics here because we want to exclude the metrics
          # added using `add_metric` API.
          return {
              m.name: m for m in model._compile_metric_functions
          }  # pylint: disable=protected-access
      return None
  
imports: import collections
  import copy
  import os
  from tensorflow.python.eager import def_function
  from tensorflow.python.keras import backend
  from tensorflow.python.keras import losses
  from tensorflow.python.keras import optimizer_v1
  from tensorflow.python.keras import optimizers
  from tensorflow.python.keras.engine import base_layer_utils
  from tensorflow.python.keras.utils import generic_utils
  from tensorflow.python.keras.utils import version_utils
  from tensorflow.python.keras.utils.io_utils import ask_to_proceed_with_overwrite
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 for calling a global function with example usage: extract_model_metrics(model) and returns: None, unknown