code: def save_model_v1(
      graph_def: graph_pb2.GraphDef,
      output_dir: str,
      signature_def_map: _SignatureDefMap,
      tags: Collection[str],
      init_op_name: Optional[str] = None,
      saver_def: Optional[saver_pb2.SaverDef] = None,
      checkpoint_dir: Optional[str] = None,
      function_aliases: Optional[Mapping[str, str]] = None,
      asset_file_defs: Sequence[meta_graph_pb2.AssetFileDef] = (),
  ) -> None:
      """Saves the model.
  
      Saves the provided graph def as SavedModel.
      Uses TF1 SavedModel semantics (i.e. no object graph).
  
      Args:
        graph_def: Graph to save.
        output_dir: Output directory for the SavedModel.
        signature_def_map: Mapping of signature def key -> SignatureDef.
        tags: Tags for the meta graph def.
        init_op_name: Name of the node for initialization.
        saver_def: `saver_pb2.SaverDef` to create a `saver.Saver` from. The created
          saver will be used to save and load variables. This may be `None` if no
          variables exist in the graph.
        checkpoint_dir: Path to checkpoint file where variable values are saved.
        function_aliases: Function name -> function alias mapping.
        asset_file_defs: `AssetFileDef`s that associates the asset files and the
          name of the tensors to which the asset file names should be fed. The
          caller should make sure the asset files exist in the output saved model
          directory.
  
      Raises:
        ValueError iff the graph does not contain a valid signature or the file
        prefix tensor is not found in the graph.
      """
      _create_empty_output_dir(output_dir)
      v1_builder = builder.SavedModelBuilder(output_dir)
  
      graph_def = _restore_output_tensor_names(graph_def)
      with session.Session(graph=ops.Graph()) as sess:
          importer.import_graph_def(graph_def, name="")
  
          signature_def_map = _validate_signatures(
              signature_def_map, ops.get_default_graph()
          )
  
          # Add `AssetFileDef`s to the collection so that correct values are fed to
          # the tensors that accept asset file paths.
          for asset_file_def in asset_file_defs:
              asset_any_proto = Any()
              asset_any_proto.Pack(asset_file_def)
              ops.add_to_collection(
                  saved_model_constants.ASSETS_KEY,
                  asset_any_proto,
              )
  
          model_saver = None
          # If `saver_def` is not None, it means there are variables in the graph.
          if saver_def:
              model_saver = saver.Saver(saver_def=saver_def)
              logging.info("Saver created with SaverDef: %s", saver_def)
  
              # Variables should be restored once before exporting as saved model
              # because the variables are not initialized when the GraphDef was
              # imported.
              model_saver.restore(sess, checkpoint_dir)
  
          v1_builder.add_meta_graph_and_variables(
              sess,
              tags,
              signature_def_map=signature_def_map,
              main_op=_find_op(sess.graph, op_name=init_op_name),
              saver=model_saver,
          )
  
      v1_builder.save()
  
      if function_aliases:
          _save_function_alias(output_dir, tags, function_aliases)
  
imports: from typing import Collection, Dict, Mapping, Optional, Sequence
  from absl import logging
  from google.protobuf.any_pb2 import Any
  from tensorflow.core.framework import graph_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.client import session
  from tensorflow.python.framework import importer
  from tensorflow.python.framework import ops
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.saved_model import builder
  from tensorflow.python.saved_model import constants
  from tensorflow.python.saved_model import loader_impl
  from tensorflow.python.saved_model import tag_constants
  from tensorflow.python.training import saver
label_desc: Use image node_id 7 for calling a global function with example usage: save_model_v1(graph_def, output_dir, signature_def_map, tags, init_op_name, saver_def, checkpoint_dir, function_aliases, asset_file_defs) without return types