class_docstr: ExportArchive is used to write SavedModel artifacts (e.g. for inference).
  
  If you have a Keras model or layer that you want to export as SavedModel for
  serving (e.g. via TensorFlow-Serving), you can use `ExportArchive`
  to configure the different serving endpoints you need to make available,
  as well as their signatures. Simply instantiate an `ExportArchive`,
  use `track()` to register the layer(s) or model(s) to be used,
  then use the `add_endpoint()` method to register a new serving endpoint.
  When done, use the `write_out()` method to save the artifact.
  
  The resulting artifact is a SavedModel and can be reloaded via
  `tf.saved_model.load`.
  
  Examples:
  
  Here's how to export a model for inference.
  
  ```python
  export_archive = ExportArchive()
  export_archive.track(model)
  export_archive.add_endpoint(
      name="serve",
      fn=model.call,
      input_signature=[tf.TensorSpec(shape=(None, 3), dtype=tf.float32)],
  )
  export_archive.write_out("path/to/location")
  
  # Elsewhere, we can reload the artifact and serve it.
  # The endpoint we added is available as a method:
  serving_model = tf.saved_model.load("path/to/location")
  outputs = serving_model.serve(inputs)
  ```
  
  Here's how to export a model with one endpoint for inference and one
  endpoint for a training-mode forward pass (e.g. with dropout on).
  
  ```python
  export_archive = ExportArchive()
  export_archive.track(model)
  export_archive.add_endpoint(
      name="call_inference",
      fn=lambda x: model.call(x, training=False),
      input_signature=[tf.TensorSpec(shape=(None, 3), dtype=tf.float32)],
  )
  export_archive.add_endpoint(
      name="call_training",
      fn=lambda x: model.call(x, training=True),
      input_signature=[tf.TensorSpec(shape=(None, 3), dtype=tf.float32)],
  )
  export_archive.write_out("path/to/location")
  ```
  
  **Note on resource tracking:**
  
  `ExportArchive` is able to automatically track all `tf.Variables` used
  by its endpoints, so most of the time calling `.track(model)`
  is not strictly required. However, if your model uses lookup layers such
  as `IntegerLookup`, `StringLookup`, or `TextVectorization`,
  it will need to be tracked explicitly via `.track(model)`.
  
  Explicit tracking is also required if you need to be able to access
  the properties `variables`, `trainable_variables`, or
  `non_trainable_variables` on the revived archive.
class_docstr_tok: ["ExportArchive","is","used","to","write","SavedModel","artifacts","(","e.g",".","for","inference",")",".","If","you","have","a","Keras","model","or","layer","that","you","want","to","export","as","SavedModel","for","serving","(","e.g",".","via","TensorFlow-Serving",")",",","you","can","use","`","ExportArchive","`","to","configure","the","different","serving","endpoints","you","need","to","make","available",",","as","well","as","their","signatures",".","Simply","instantiate","an","`","ExportArchive","`",",","use","`","track","(",")","`","to","register","the","layer","(","s",")","or","model","(","s",")","to","be","used",",","then","use","the","`","add_endpoint","(",")","`","method","to","register","a","new","serving","endpoint",".","When","done",",","use","the","`","write_out","(",")","`","method","to","save","the","artifact",".","The","resulting","artifact","is","a","SavedModel","and","can","be","reloaded","via","`","tf.saved_model.load","`",".","Examples",":","Here","'s","how","to","export","a","model","for","inference",".","``","`","python","export_archive","=","ExportArchive","(",")","export_archive.track","(","model",")","export_archive.add_endpoint","(","name=","''","serve","''",",","fn=model.call",",","input_signature=","[","tf.TensorSpec","(","shape=","(","None",",","3",")",",","dtype=tf.float32",")","]",",",")","export_archive.write_out","(","``","path\/to\/location","''",")","#","Elsewhere",",","we","can","reload","the","artifact","and","serve","it",".","#","The","endpoint","we","added","is","available","as","a","method",":","serving_model","=","tf.saved_model.load","(","``","path\/to\/location","''",")","outputs","=","serving_model.serve","(","inputs",")","``","`","Here","'s","how","to","export","a","model","with","one","endpoint","for","inference","and","one","endpoint","for","a","training-mode","forward","pass","(","e.g",".","with","dropout","on",")",".","``","`","python","export_archive","=","ExportArchive","(",")","export_archive.track","(","model",")","export_archive.add_endpoint","(","name=","''","call_inference","''",",","fn=lambda","x",":","model.call","(","x",",","training=False",")",",","input_signature=","[","tf.TensorSpec","(","shape=","(","None",",","3",")",",","dtype=tf.float32",")","]",",",")","export_archive.add_endpoint","(","name=","''","call_training","''",",","fn=lambda","x",":","model.call","(","x",",","training=True",")",",","input_signature=","[","tf.TensorSpec","(","shape=","(","None",",","3",")",",","dtype=tf.float32",")","]",",",")","export_archive.write_out","(","``","path\/to\/location","''",")","``","`","*","*","Note","on","resource","tracking",":","*","*","`","ExportArchive","`","is","able","to","automatically","track","all","`","tf.Variables","`","used","by","its","endpoints",",","so","most","of","the","time","calling","`",".track","(","model",")","`","is","not","strictly","required",".","However",",","if","your","model","uses","lookup","layers","such","as","`","IntegerLookup","`",",","`","StringLookup","`",",","or","`","TextVectorization","`",",","it","will","need","to","be","tracked","explicitly","via","`",".track","(","model",")","`",".","Explicit","tracking","is","also","required","if","you","need","to","be","able","to","access","the","properties","`","variables","`",",","`","trainable_variables","`",",","or","`","non_trainable_variables","`","on","the","revived","archive","."]
docstr: Write the corresponding SavedModel to disk.
  
  Arguments:
      filepath: `str` or `pathlib.Path` object.
          Path where to save the artifact.
      options: `tf.saved_model.SaveOptions` object that specifies
          SavedModel saving options.
  
  **Note on TF-Serving**: all endpoints registered via `add_endpoint()`
  are made visible for TF-Serving in the SavedModel artifact. In addition,
  the first endpoint registered is made visible under the alias
  `"serving_default"` (unless an endpoint with the name
  `"serving_default"` was already registered manually),
  since TF-Serving requires this endpoint to be set.
docstr_tok: ["Write","the","corresponding","SavedModel","to","disk",".","Arguments",":","filepath",":","`","str","`","or","`","pathlib.Path","`","object",".","Path","where","to","save","the","artifact",".","options",":","`","tf.saved_model.SaveOptions","`","object","that","specifies","SavedModel","saving","options",".","*","*","Note","on","TF-Serving","*","*",":","all","endpoints","registered","via","`","add_endpoint","(",")","`","are","made","visible","for","TF-Serving","in","the","SavedModel","artifact",".","In","addition",",","the","first","endpoint","registered","is","made","visible","under","the","alias","`","``","serving_default","''","`","(","unless","an","endpoint","with","the","name","`","``","serving_default","''","`","was","already","registered","manually",")",",","since","TF-Serving","requires","this","endpoint","to","be","set","."]
code: def write_out(self, filepath, options=None):
      """Write the corresponding SavedModel to disk.
  
      Arguments:
          filepath: `str` or `pathlib.Path` object.
              Path where to save the artifact.
          options: `tf.saved_model.SaveOptions` object that specifies
              SavedModel saving options.
  
      **Note on TF-Serving**: all endpoints registered via `add_endpoint()`
      are made visible for TF-Serving in the SavedModel artifact. In addition,
      the first endpoint registered is made visible under the alias
      `"serving_default"` (unless an endpoint with the name
      `"serving_default"` was already registered manually),
      since TF-Serving requires this endpoint to be set.
      """
      if not self._endpoint_names:
          raise ValueError(
              "No endpoints have been set yet. Call add_endpoint()."
          )
      if backend.backend() == "tensorflow":
          self._filter_and_track_resources()
  
      signatures = {}
      for name in self._endpoint_names:
          signatures[name] = self._get_concrete_fn(name)
      # Add "serving_default" signature key for TFServing
      if "serving_default" not in self._endpoint_names:
          signatures["serving_default"] = self._get_concrete_fn(
              self._endpoint_names[0]
          )
  
      tf.saved_model.save(
          self._tf_trackable,
          filepath,
          options=options,
          signatures=signatures,
      )
  
      # Print out available endpoints
      endpoints = "\n\n".join(
          _print_signature(getattr(self._tf_trackable, name), name)
          for name in self._endpoint_names
      )
      io_utils.print_msg(
          f"Saved artifact at '{filepath}'. "
          "The following endpoints are available:\n\n"
          f"{endpoints}"
      )
  
imports: from absl import logging
  from keras import backend
  from keras.api_export import keras_export
  from keras.layers import Layer
  from keras.models import Functional
  from keras.models import Sequential
  from keras.utils import io_utils
  from keras.utils.module_utils import tensorflow
label_desc: Use image node_id 8 for calling the ExportArchive obj's underlying member method code with example usage: obj.write_out(filepath, options) without return types