code: def _parse_saved_model_signatures(  # pylint: disable=invalid-name
      model_path: str,
      tag_set: Iterable[str],
      signature_names: Iterable[str],
  ) -> Mapping[str, _SignatureDef]:
      """Parse SignatureDefs of given signature names from SavedModel.
  
      Among one or more MetaGraphDefs in SavedModel, the first one that has all the
      tag_set elements is chosen. Selected MetaGraphDef should have signatures for
      all given signature names.
  
      Args:
        model_path: A path to the SavedModel directory.
        tag_set: A set of tags MetaGraphDef should have.
        signature_names: A list of signature names to retrieve.
  
      Returns:
        A mapping from signature name to SignatureDef.
      """
      if not tag_set:
          tag_set = {tf.saved_model.SERVING}
          logging.info(
              "tag_set is not given. Using %r instead.", tag_set
          )
      if not signature_names:
          signature_names = [
              tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY
          ]
          logging.info(
              "signature_names are not given. Using %r instead.",
              signature_names,
          )
      loader = loader_impl.SavedModelLoader(model_path)
      meta_graph_def = loader.get_meta_graph_def_from_tags(tag_set)
      result = {}
      for signature_name in signature_names:
          if signature_name not in meta_graph_def.signature_def:
              raise ValueError(
                  "SignatureDef of name {} could not be found in "
                  "MetaGraphDef".format(signature_name)
              )
          result[signature_name] = meta_graph_def.signature_def[
              signature_name
          ]
      return result
  
imports: import abc
  import os
  from typing import Any, Iterable, List, Mapping, Optional
  from absl import logging
  import tensorflow
  from tfx import types
  from tfx.components.infra_validator import types
  from tfx.components.util import examples_utils
  from tfx.components.util import tfxio_utils
  from tfx.dsl.io import fileio
  from tfx.proto import example_gen_pb2
  from tfx.proto import infra_validator_pb2
  from tfx.types import artifact_utils
  from tfx.utils import path_utils
  from tfx_bsl.tfxio import dataset_options
  from tensorflow.python.saved_model import loader_impl
  from tensorflow_serving.apis import classification_pb2
  from tensorflow_serving.apis import predict_pb2
  from tensorflow_serving.apis import regression_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _parse_saved_model_signatures(model_path, tag_set, signature_names) and returns: result