code: def export_saved_model(sess, export_dir, tag_set, signatures):
      """Convenience function to export a saved_model using provided arguments
  
      The caller specifies the saved_model signatures in a simplified python dictionary form, as follows::
  
        signatures = {
          'signature_def_key': {
            'inputs': { 'input_tensor_alias': input_tensor_name },
            'outputs': { 'output_tensor_alias': output_tensor_name },
            'method_name': 'method'
          }
        }
  
      And this function will generate the `signature_def_map` and export the saved_model.
  
      DEPRECATED for TensorFlow 2.x+.
  
      Args:
        :sess: a tf.Session instance
        :export_dir: path to save exported saved_model
        :tag_set: string tag_set to identify the exported graph
        :signatures: simplified dictionary representation of a TensorFlow signature_def_map
  
      Returns:
        A saved_model exported to disk at ``export_dir``.
      """
      import tensorflow as tf
  
      if version.parse(tf.__version__) >= version.parse("2.0.0"):
          raise Exception("DEPRECATED: Use TF provided APIs instead.")
  
      g = sess.graph
      g._unsafe_unfinalize()  # https://github.com/tensorflow/serving/issues/363
      builder = tf.saved_model.builder.SavedModelBuilder(export_dir)
  
      logging.info("===== signatures: {}".format(signatures))
      signature_def_map = {}
      for key, sig in signatures.items():
          signature_def_map[
              key
          ] = tf.saved_model.signature_def_utils.build_signature_def(
              inputs={
                  name: tf.saved_model.utils.build_tensor_info(tensor)
                  for name, tensor in sig["inputs"].items()
              },
              outputs={
                  name: tf.saved_model.utils.build_tensor_info(tensor)
                  for name, tensor in sig["outputs"].items()
              },
              method_name=sig["method_name"]
              if "method_name" in sig
              else key,
          )
      logging.info(
          "===== signature_def_map: {}".format(signature_def_map)
      )
      builder.add_meta_graph_and_variables(
          sess,
          tag_set.split(","),
          signature_def_map=signature_def_map,
          clear_devices=True,
      )
      g.finalize()
      builder.save()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import nested_scopes
  from __future__ import print_function
  import getpass
  import logging
  import pkg_resources
  from packaging import version
  from six.moves.queue import Empty
  from .None import compat, marker
label_desc: Use image node_id 4 for calling a global function with example usage: export_saved_model(sess, export_dir, tag_set, signatures) without return types