class_docstr: Helper class for managing experiment-level checkpoints.
  
  This class implements the ``checkpoint()`` method used to checkpoint
  experiment state. When called, this will serialize and write to disk
  the state of the trial runner, trial executor, and search algorithm, to
  a specified checkpoint file.
  
  The checkpoint period is automatically adjusted to
  ``max(10, time_per_checkpoint * 19)``. This means that at most 5% of the
  time (1/20) will be used for writing checkpoints, while 95% of the time
  (19/20) will be used to handle the rest of the training loop.
  
  If ``sync_every_n_trial_checkpoints`` is not None, syncing
  to cloud will be forced if any trial has checkpointed more times than
  ``sync_every_n_trial_checkpoints`` since last sync.
class_docstr_tok: ["Helper","class","for","managing","experiment-level","checkpoints",".","This","class","implements","the","``","checkpoint","(",")","``","method","used","to","checkpoint","experiment","state",".","When","called",",","this","will","serialize","and","write","to","disk","the","state","of","the","trial","runner",",","trial","executor",",","and","search","algorithm",",","to","a","specified","checkpoint","file",".","The","checkpoint","period","is","automatically","adjusted","to","``","max","(","10",",","time_per_checkpoint","*","19",")","``",".","This","means","that","at","most","5","%","of","the","time","(","1\/20",")","will","be","used","for","writing","checkpoints",",","while","95","%","of","the","time","(","19\/20",")","will","be","used","to","handle","the","rest","of","the","training","loop",".","If","``","sync_every_n_trial_checkpoints","``","is","not","None",",","syncing","to","cloud","will","be","forced","if","any","trial","has","checkpointed","more","times","than","``","sync_every_n_trial_checkpoints","``","since","last","sync","."]
docstr: Checks whether to resume experiment.
  
  If experiment should be resumed, this method may sync down experiment state
  from the cloud and then return a ResumeConfig mapping to the resume type.
  
  Args:
      resume_type: One of ["REMOTE", "LOCAL", "PROMPT", "AUTO"]. Can
          be suffixed with one or more of ["+ERRORED", "+ERRORED_ONLY",
          "+RESTART_ERRORED", "+RESTART_ERRORED_ONLY"]
  
  Returns:
      _ResumeConfig if resume is successful. None otherwise.
docstr_tok: ["Checks","whether","to","resume","experiment",".","If","experiment","should","be","resumed",",","this","method","may","sync","down","experiment","state","from","the","cloud","and","then","return","a","ResumeConfig","mapping","to","the","resume","type",".","Args",":","resume_type",":","One","of","[","``","REMOTE","''",",","``","LOCAL","''",",","``","PROMPT","''",",","``","AUTO","''","]",".","Can","be","suffixed","with","one","or","more","of","[","``","+ERRORED","''",",","``","+ERRORED_ONLY","''",",","``","+RESTART_ERRORED","''",",","``","+RESTART_ERRORED_ONLY","''","]","Returns",":","_ResumeConfig","if","resume","is","successful",".","None","otherwise","."]
code: def resume(
      self, resume_type: Union[str, bool]
  ) -> Optional[_ResumeConfig]:
      """Checks whether to resume experiment.
  
      If experiment should be resumed, this method may sync down experiment state
      from the cloud and then return a ResumeConfig mapping to the resume type.
  
      Args:
          resume_type: One of ["REMOTE", "LOCAL", "PROMPT", "AUTO"]. Can
              be suffixed with one or more of ["+ERRORED", "+ERRORED_ONLY",
              "+RESTART_ERRORED", "+RESTART_ERRORED_ONLY"]
  
      Returns:
          _ResumeConfig if resume is successful. None otherwise.
      """
      if not resume_type:
          return None
  
      resume_type, resume_config = _resume_str_to_config(resume_type)
  
      experiment_local_path = self._storage.experiment_local_path
      experiment_fs_path = self._storage.experiment_fs_path
  
      if resume_type == "AUTO":
          if self._resume_auto():
              return resume_config
          # Else
          return None
  
      if resume_type in ["LOCAL", "PROMPT"]:
          if not _experiment_checkpoint_exists(experiment_local_path):
              raise ValueError(
                  f"You called resume ({resume_type}) when no checkpoint "
                  f"exists in local directory "
                  f"({experiment_local_path}). If you want to start "
                  f'a new experiment, use `resume="AUTO"` or '
                  f"`resume=None`. If you expected an experiment to "
                  f"already exist, check if you supplied the correct "
                  f"`local_dir` to `train.RunConfig()`."
              )
          elif resume_type == "PROMPT":
              if click.confirm(
                  f"Resume from local directory? "
                  f"({experiment_local_path})"
              ):
                  return resume_config
  
      if resume_type in ["REMOTE", "PROMPT"]:
          if resume_type == "PROMPT" and not click.confirm(
              f"Try downloading from remote directory? "
              f"({experiment_fs_path})"
          ):
              return None
  
          # Try syncing down the upload directory.
          logger.info(
              f"Downloading experiment checkpoint from "
              f"{experiment_fs_path}"
          )
          self.sync_down_experiment_state()
  
          if not _experiment_checkpoint_exists(experiment_local_path):
              raise ValueError(
                  "Called resume when no checkpoint exists "
                  "in remote or local directory."
              )
      return resume_config
  
imports: from collections import Counter
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Callable, Dict, Optional, Tuple, Union
  import click
  import logging
  import os
  import time
  import warnings
  from ray.train._internal.storage import StorageContext, get_fs_and_path, _download_from_fs_path, _list_at_fs_path
  from ray.tune.experiment import Trial
  from ray.tune.impl.out_of_band_serialize_dataset import out_of_band_serialize_dataset
label_desc: Use image node_id 9 for calling the _ExperimentCheckpointManager obj's underlying member method code with example usage: obj.resume(resume_type) and returns: resume_config, None, None, resume_config, None, resume_config