code: def add_meta_graph_and_variables(
      self,
      sess,
      tags,
      signature_def_map=None,
      assets_collection=None,
      legacy_init_op=None,
      clear_devices=False,
      main_op=None,
      strip_default_attrs=False,
      saver=None,
  ):
      if self._has_saved_variables:
          raise AssertionError(
              "Graph state including variables and assets has "
              "already been saved. Please invoke "
              "`add_meta_graph()` instead."
          )
  
      # Validate the signature def map to ensure all included TensorInfos are
      # properly populated.
      signature_def_map = signature_def_map or {}
      self._validate_signature_def_map(signature_def_map)
  
      # legacy_init_op is deprecated, and going away in TF 2.0.
      # Re-mapping to main_op, as treatment is identical regardless.
      main_op = main_op or legacy_init_op
  
      # Add assets and ops
      self._add_collections(assets_collection, main_op, None)
  
      path_helpers.get_or_create_variables_dir(self._export_dir)
      variables_path = path_helpers.get_variables_path(self._export_dir)
  
      saver = self._maybe_create_saver(saver)
  
      # Save the variables. Also, disable writing the checkpoint state proto. The
      # file is not used during SavedModel loading. In addition, since a
      # SavedModel can be copied or moved, this avoids the checkpoint state to
      # become outdated.
      saver.save(
          sess,
          variables_path,
          write_meta_graph=False,
          write_state=False,
      )
  
      # Export the meta graph def.
  
      # The graph almost certainly previously contained at least one Saver, and
      # possibly several (e.g. one for loading a pretrained embedding, and another
      # for the model weights).  Removing the preexisting ones was the
      # motivation for the clear_extraneous_savers option, but it turns out that
      # there are edge cases where that option breaks the graph.  Until that is
      # resolved, we just leave the option set to False for now.
      # TODO(soergel): Reinstate clear_extraneous_savers=True when possible.
      meta_graph_def = saver.export_meta_graph(
          clear_devices=clear_devices,
          strip_default_attrs=strip_default_attrs,
      )
  
      # Tag the meta graph def and add it to the SavedModel.
      self._tag_and_add_meta_graph(
          meta_graph_def, tags, signature_def_map
      )
  
      # Mark this instance of SavedModel as having saved variables, such that
      # subsequent attempts to save variables will fail.
      self._has_saved_variables = True
  
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 7 for calling the SavedModelBuilder obj's underlying member method code with example usage: obj.add_meta_graph_and_variables(sess, tags, signature_def_map, assets_collection, legacy_init_op, clear_devices, main_op, strip_default_attrs, saver) without return types