code: def load_metrics(
      signature_def: tf.compat.v1.MetaGraphDef.SignatureDefEntry,
      graph: tf.Graph,
  ) -> Dict[types.FPLKeyType, Dict[str, types.TensorType]]:
      """Loads metric nodes from signature_def.outputs.
  
      Args:
        signature_def: SignatureDef to lookup nodes in.
        graph: TensorFlow graph to lookup the nodes in.
  
      Returns:
        Metrics map as an OrderedDict.
      """
      metrics = extract_signature_inputs_or_outputs_with_prefix(
          constants.METRICS_NAME, signature_def.outputs
      )
      metrics_map = collections.defaultdict(dict)
      for k, v in metrics.items():
          node = tf.compat.v1.saved_model.utils.get_tensor_from_tensor_info(
              v, graph
          )
  
          if k.endswith("/" + constants.METRIC_VALUE_SUFFIX):
              key = k[: -len(constants.METRIC_VALUE_SUFFIX) - 1]
              metrics_map[key][encoding.VALUE_OP_SUFFIX] = node
          elif k.endswith("/" + constants.METRIC_UPDATE_SUFFIX):
              key = k[: -len(constants.METRIC_UPDATE_SUFFIX) - 1]
              metrics_map[key][encoding.UPDATE_OP_SUFFIX] = node
          else:
              raise ValueError(
                  "unrecognised suffix for metric. key was: %s" % k
              )
      return metrics_map
  
imports: import collections
  from typing import Dict, List, Optional, Tuple, Union
  import tensorflow
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.eval_saved_model import constants
  from tensorflow_model_analysis.eval_saved_model import encoding
  from tensorflow_model_analysis.eval_saved_model import util
  from google.protobuf import any_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
label_desc: Use image node_id 9 for calling a global function with example usage: load_metrics(signature_def, graph) and returns: metrics_map