class_docstr: Same as :class:`TrainConfig`, but does the following to automatically
  resume from training:
  
  1. If a checkpoint was found in :meth:`logger.get_logger_dir()`, set
     `session_init` option to load it.
  2. If a JSON history was found in :meth:`logger.get_logger_dir()`, try to
     load the epoch number from it and set the `starting_epoch` option to
     continue training.
  
  You can choose to let the above two option to either overwrite or
  not overwrite user-provided arguments, as explained below.
  
  Note that the functionality requires the logging directory to obtain
  necessary information from a previous run.
  If you have unconventional setup of logging directory, this class will not
  work for you, for example:
  
      1. If you save the checkpoint to a different directory rather than the
         logging directory.
  
      2. If in distributed training the directory is not
         available to every worker, or the directories are different for different workers.
class_docstr_tok: ["Same","as",":","class",":","`","TrainConfig","`",",","but","does","the","following","to","automatically","resume","from","training",":","1",".","If","a","checkpoint","was","found","in",":","meth",":","`","logger.get_logger_dir","(",")","`",",","set","`","session_init","`","option","to","load","it",".","2",".","If","a","JSON","history","was","found","in",":","meth",":","`","logger.get_logger_dir","(",")","`",",","try","to","load","the","epoch","number","from","it","and","set","the","`","starting_epoch","`","option","to","continue","training",".","You","can","choose","to","let","the","above","two","option","to","either","overwrite","or","not","overwrite","user-provided","arguments",",","as","explained","below",".","Note","that","the","functionality","requires","the","logging","directory","to","obtain","necessary","information","from","a","previous","run",".","If","you","have","unconventional","setup","of","logging","directory",",","this","class","will","not","work","for","you",",","for","example",":","1",".","If","you","save","the","checkpoint","to","a","different","directory","rather","than","the","logging","directory",".","2",".","If","in","distributed","training","the","directory","is","not","available","to","every","worker",",","or","the","directories","are","different","for","different","workers","."]
docstr: Args:
      always_resume (bool): If False, user-provided arguments
          `session_init` and `starting_epoch` will take priority.
          Otherwise, resume will take priority.
      kwargs: same as in :class:`TrainConfig`.
  
  Note:
      The main goal of this class is to let a training job resume
      without changing any line of code or command line arguments.
      So it's useful to let resume take priority over user-provided arguments sometimes.
  
      For example: if your training starts from a pre-trained model,
      you would want it to use user-provided model loader at the
      beginning, but a "resume" model loader when the job was
      interrupted and restarted.
docstr_tok: ["Args",":","always_resume","(","bool",")",":","If","False",",","user-provided","arguments","`","session_init","`","and","`","starting_epoch","`","will","take","priority",".","Otherwise",",","resume","will","take","priority",".","kwargs",":","same","as","in",":","class",":","`","TrainConfig","`",".","Note",":","The","main","goal","of","this","class","is","to","let","a","training","job","resume","without","changing","any","line","of","code","or","command","line","arguments",".","So","it","'s","useful","to","let","resume","take","priority","over","user-provided","arguments","sometimes",".","For","example",":","if","your","training","starts","from","a","pre-trained","model",",","you","would","want","it","to","use","user-provided","model","loader","at","the","beginning",",","but","a","``","resume","''","model","loader","when","the","job","was","interrupted","and","restarted","."]
code: def __init__(self, always_resume=True, **kwargs):
      """
      Args:
          always_resume (bool): If False, user-provided arguments
              `session_init` and `starting_epoch` will take priority.
              Otherwise, resume will take priority.
          kwargs: same as in :class:`TrainConfig`.
  
      Note:
          The main goal of this class is to let a training job resume
          without changing any line of code or command line arguments.
          So it's useful to let resume take priority over user-provided arguments sometimes.
  
          For example: if your training starts from a pre-trained model,
          you would want it to use user-provided model loader at the
          beginning, but a "resume" model loader when the job was
          interrupted and restarted.
      """
      found_sessinit = False
      if always_resume or "session_init" not in kwargs:
          sessinit = self.get_sessinit_resume()
          if sessinit is not None:
              found_sessinit = True
              path = sessinit.path
              if "session_init" in kwargs:
                  logger.info(
                      "Found checkpoint at {}. "
                      "session_init arguments will be overwritten.".format(
                          path
                      )
                  )
              else:
                  logger.info(
                      "Will load checkpoint at {}.".format(path)
                  )
              kwargs["session_init"] = sessinit
  
      found_last_epoch = False
      if always_resume or "starting_epoch" not in kwargs:
          last_epoch = JSONWriter.load_existing_epoch_number()
          if last_epoch is not None:
              found_last_epoch = True
              now_epoch = last_epoch + 1
              logger.info(
                  "Found history statistics from JSON. "
                  "Setting starting_epoch to {}.".format(now_epoch)
              )
              kwargs["starting_epoch"] = now_epoch
      assert (
          found_sessinit == found_last_epoch
      ), "Found SessionInit={}, Found Last Epoch={}".format(
          found_sessinit, found_last_epoch
      )
  
      super(AutoResumeTrainConfig, self).__init__(**kwargs)
  
file_path: tensorpack/tensorpack/train/config.py
imports: import os
  from ..compat import tfv1
  from ..callbacks import JSONWriter, MergeAllSummaries, MovingAverageSummary, ProgressBar, RunUpdateOps, ScalarPrinter, TFEventWriter
  from ..dataflow.base import DataFlow
  from ..input_source import InputSource
  from ..tfutils.sesscreate import NewSessionCreator
  from ..tfutils.sessinit import SaverRestore, SessionInit
  from ..utils import logger
  from .model_desc import ModelDescBase
label_desc: Use image node_id 1 to create a new AutoResumeTrainConfig object from inherited base classes: TrainConfig with example: obj = AutoResumeTrainConfig(always_resume)