class_docstr: A wrapper upon tf.compat.v1.train.Saver.
docstr: Saver for AutoDist.
  
  This saver saves the variables that maps to the *original*, *user-declared*, *single-node* graph,
  instead of the transformed graph. Hence, the saved variables can be loaded either by the original
  user code (for resuming single-node training or inference), or by the AutoDist-distributed code (to
  resume distributed training). Differently, AutoDist saver saves the meta_graph_def that maps to the
  *AutoDist transformed* graph (TODO).
  
  AutoDist saver implements this by writing/loading the contents that maps to the master_replica
  (default to replica_index=0) of the transformed graph.
  
  Refer to https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/training/saver.py
  for a detailed explanation of the signature.
code: def __init__(
      self,
      var_list=None,
      reshape=False,
      sharded=False,
      max_to_keep=5,
      keep_checkpoint_every_n_hours=10000.0,
      name=None,
      restore_sequentially=False,
      saver_def=None,
      builder=None,
      defer_build=False,
      allow_empty=False,
      write_version=saver_pb2.SaverDef.V2,
      pad_step_number=False,
      save_relative_paths=False,
      filename=None,
  ):
      # pylint: disable=too-many-arguments, too-many-locals
      """
      Saver for AutoDist.
  
      This saver saves the variables that maps to the *original*, *user-declared*, *single-node* graph,
      instead of the transformed graph. Hence, the saved variables can be loaded either by the original
      user code (for resuming single-node training or inference), or by the AutoDist-distributed code (to
      resume distributed training). Differently, AutoDist saver saves the meta_graph_def that maps to the
      *AutoDist transformed* graph (TODO).
  
      AutoDist saver implements this by writing/loading the contents that maps to the master_replica
      (default to replica_index=0) of the transformed graph.
  
      Refer to https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/training/saver.py
      for a detailed explanation of the signature.
      """
      # TODO(Hao): support constructing saver after AutoDist graph transformation
      _autodist = autodist.autodist.get_default_autodist()
      if _autodist.is_built():
          raise ValueError(
              "Saver must be used before create_distributed_session()."
          )
  
      # A saver will append relevant save/restore ops to all variables in var_list, i.e. one saver
      # maps to all variables, and encloses them under a "saver" scope.
      super(Saver, self).__init__(
          var_list=var_list,
          reshape=reshape,
          sharded=sharded,
          max_to_keep=max_to_keep,
          keep_checkpoint_every_n_hours=keep_checkpoint_every_n_hours,
          name=name,
          restore_sequentially=restore_sequentially,
          saver_def=saver_def,
          builder=builder,
          defer_build=defer_build,
          allow_empty=allow_empty,
          write_version=write_version,
          pad_step_number=pad_step_number,
          save_relative_paths=save_relative_paths,
          filename=filename,
      )
  
      # Note: tensorflow does not add user-declared saver to collections, so have to track it in info.
      item = get_default_graph_item()
      new_saver_def = saver_pb2.SaverDef()
      new_saver_def.CopyFrom(self.to_proto())
      item.info.update_savers([new_saver_def], replace=False)
  
file_path: autodist/autodist/checkpoint/saver.py
imports: from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.training import saver
  import autodist.autodist
  from autodist.graph_item import get_default_graph_item
label_desc: Use image node_id 1 to create a new Saver object from inherited base classes: tf_saver with example: obj = Saver(var_list, reshape, sharded, max_to_keep, keep_checkpoint_every_n_hours, name, restore_sequentially, saver_def, builder, defer_build, allow_empty, write_version, pad_step_number, save_relative_paths, filename)