<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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. 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
  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()