class_docstr: Builds the `SavedModel` protocol buffer and saves variables and assets.
  
  The `SavedModelBuilder` class provides the functionality to build a
  `SavedModel` protocol buffer. Specifically, this allows multiple meta
  graphs to be saved as part of a single language-neutral `SavedModel`,
  while sharing variables and assets.
  
  To build a SavedModel, the first meta graph must be saved with variables.
  Subsequent meta graphs will simply be saved with their graph definitions. If
  assets need to be saved and written or copied to disk, they can be provided
  when the meta graph def is added. If multiple meta graph defs are associated
  an asset of the same name, only the first version is retained.
  
  Each meta graph added to the SavedModel must be annotated with tags. The tags
  provide a means to identify the specific meta graph to load and restore, along
  with the shared set of variables and assets.
  
  Typical usage for the `SavedModelBuilder`:
  
  ```python
  ...
  builder = tf.compat.v1.saved_model.Builder(export_dir)
  
  with tf.compat.v1.Session(graph=tf.Graph()) as sess:
    ...
    builder.add_meta_graph_and_variables(sess,
                                    ["foo-tag"],
                                    signature_def_map=foo_signatures,
                                    assets_list=foo_assets)
  ...
  
  with tf.compat.v1.Session(graph=tf.Graph()) as sess:
    ...
    builder.add_meta_graph(["bar-tag", "baz-tag"])
  ...
  
  builder.save()
  ```
  
  Note: This function will only be available through the v1 compatibility
  library as tf.compat.v1.saved_model.builder.SavedModelBuilder or
  tf.compat.v1.saved_model.Builder. Tensorflow 2.0 will introduce a new
  object-based method of creating SavedModels.
class_docstr_tok: ["Builds","the","`","SavedModel","`","protocol","buffer","and","saves","variables","and","assets",".","The","`","SavedModelBuilder","`","class","provides","the","functionality","to","build","a","`","SavedModel","`","protocol","buffer",".","Specifically",",","this","allows","multiple","meta","graphs","to","be","saved","as","part","of","a","single","language-neutral","`","SavedModel","`",",","while","sharing","variables","and","assets",".","To","build","a","SavedModel",",","the","first","meta","graph","must","be","saved","with","variables",".","Subsequent","meta","graphs","will","simply","be","saved","with","their","graph","definitions",".","If","assets","need","to","be","saved","and","written","or","copied","to","disk",",","they","can","be","provided","when","the","meta","graph","def","is","added",".","If","multiple","meta","graph","defs","are","associated","an","asset","of","the","same","name",",","only","the","first","version","is","retained",".","Each","meta","graph","added","to","the","SavedModel","must","be","annotated","with","tags",".","The","tags","provide","a","means","to","identify","the","specific","meta","graph","to","load","and","restore",",","along","with","the","shared","set","of","variables","and","assets",".","Typical","usage","for","the","`","SavedModelBuilder","`",":","``","`","python","...","builder","=","tf.compat.v1.saved_model.Builder","(","export_dir",")","with","tf.compat.v1.Session","(","graph=tf.Graph","(",")",")","as","sess",":","...","builder.add_meta_graph_and_variables","(","sess",",","[","``","foo-tag","''","]",",","signature_def_map=foo_signatures",",","assets_list=foo_assets",")","...","with","tf.compat.v1.Session","(","graph=tf.Graph","(",")",")","as","sess",":","...","builder.add_meta_graph","(","[","``","bar-tag","''",",","``","baz-tag","''","]",")","...","builder.save","(",")","``","`","Note",":","This","function","will","only","be","available","through","the","v1","compatibility","library","as","tf.compat.v1.saved_model.builder.SavedModelBuilder","or","tf.compat.v1.saved_model.Builder",".","Tensorflow","2.0","will","introduce","a","new","object-based","method","of","creating","SavedModels","."]
code: def __init__(self, export_dir):
      self._saved_model = saved_model_pb2.SavedModel()
      self._saved_model.saved_model_schema_version = (
          constants.SAVED_MODEL_SCHEMA_VERSION
      )
  
      self._export_dir = export_dir
      if file_io.file_exists(export_dir):
          if file_io.list_directory(export_dir):
              raise AssertionError(
                  f"Export directory {export_dir} already exists, and isn't empty. "
                  "Please choose a different export directory, or delete all the "
                  "contents of the specified directory."
              )
      else:
          file_io.recursive_create_dir(self._export_dir)
  
      # Boolean to track whether variables and assets corresponding to the
      # SavedModel have been saved. Specifically, the first meta graph to be added
      # MUST use the add_meta_graph_and_variables() API. Subsequent add operations
      # on the SavedModel MUST use the add_meta_graph() API which does not save
      # weights.
      self._has_saved_variables = False
      self._saved_asset_files = set()
  
imports: import functools
  import os
  from google.protobuf.any_pb2 import Any
  from tensorflow.core.framework import types_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.core.protobuf import saved_model_pb2
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.saved_model import fingerprinting_utils
  from tensorflow.python.saved_model import path_helpers
  from tensorflow.python.saved_model import signature_def_utils
  from tensorflow.python.saved_model.pywrap_saved_model import constants
  from tensorflow.python.saved_model.pywrap_saved_model import metrics
  from tensorflow.python.training import saver
  from tensorflow.python.util import compat
  from tensorflow.python.util.deprecation import deprecated_args
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 to create a new _SavedModelBuilder object from inherited base classes: object with example: obj = _SavedModelBuilder(export_dir)