class_docstr: The base class of Runner, a training helper for PyTorch.
  
  All subclasses should implement the following APIs:
  
  - ``run()``
  - ``train()``
  - ``val()``
  - ``save_checkpoint()``
  
  Args:
      model (:obj:`torch.nn.Module`): The model to be run.
      batch_processor (callable): A callable method that process a data
          batch. The interface of this method should be
          `batch_processor(model, data, train_mode) -> dict`
      optimizer (dict or :obj:`torch.optim.Optimizer`): It can be either an
          optimizer (in most cases) or a dict of optimizers (in models that
          requires more than one optimizer, e.g., GAN).
      work_dir (str, optional): The working directory to save checkpoints
          and logs. Defaults to None.
      logger (:obj:`logging.Logger`): Logger used during training.
           Defaults to None. (The default value is just for backward
           compatibility)
      meta (dict | None): A dict records some import information such as
          environment info and seed, which will be logged in logger hook.
          Defaults to None.
      max_epochs (int, optional): Total training epochs.
      max_iters (int, optional): Total training iterations.
class_docstr_tok: ["The","base","class","of","Runner",",","a","training","helper","for","PyTorch",".","All","subclasses","should","implement","the","following","APIs",":","-","``","run","(",")","``","-","``","train","(",")","``","-","``","val","(",")","``","-","``","save_checkpoint","(",")","``","Args",":","model","(",":","obj",":","`","torch.nn.Module","`",")",":","The","model","to","be","run",".","batch_processor","(","callable",")",":","A","callable","method","that","process","a","data","batch",".","The","interface","of","this","method","should","be","`","batch_processor","(","model",",","data",",","train_mode",")","-",">","dict","`","optimizer","(","dict","or",":","obj",":","`","torch.optim.Optimizer","`",")",":","It","can","be","either","an","optimizer","(","in","most","cases",")","or","a","dict","of","optimizers","(","in","models","that","requires","more","than","one","optimizer",",","e.g.",",","GAN",")",".","work_dir","(","str",",","optional",")",":","The","working","directory","to","save","checkpoints","and","logs",".","Defaults","to","None",".","logger","(",":","obj",":","`","logging.Logger","`",")",":","Logger","used","during","training",".","Defaults","to","None",".","(","The","default","value","is","just","for","backward","compatibility",")","meta","(","dict","|","None",")",":","A","dict","records","some","import","information","such","as","environment","info","and","seed",",","which","will","be","logged","in","logger","hook",".","Defaults","to","None",".","max_epochs","(","int",",","optional",")",":","Total","training","epochs",".","max_iters","(","int",",","optional",")",":","Total","training","iterations","."]
code: def resume(
      self, checkpoint, resume_optimizer=True, map_location="default"
  ):
      if map_location == "default":
          if torch.cuda.is_available():
              device_id = torch.cuda.current_device()
              checkpoint = self.load_checkpoint(
                  checkpoint,
                  map_location=lambda storage, loc: storage.cuda(
                      device_id
                  ),
              )
          else:
              checkpoint = self.load_checkpoint(checkpoint)
      else:
          checkpoint = self.load_checkpoint(
              checkpoint, map_location=map_location
          )
  
      self._epoch = checkpoint["meta"]["epoch"]
      self._iter = checkpoint["meta"]["iter"]
      if self.meta is None:
          self.meta = {}
      self.meta.setdefault("hook_msgs", {})
      # load `last_ckpt`, `best_score`, `best_ckpt`, etc. for hook messages
      self.meta["hook_msgs"].update(
          checkpoint["meta"].get("hook_msgs", {})
      )
  
      # Re-calculate the number of iterations when resuming
      # models with different number of GPUs
      if "config" in checkpoint["meta"]:
          config = mmcv.Config.fromstring(
              checkpoint["meta"]["config"], file_format=".py"
          )
          previous_gpu_ids = config.get("gpu_ids", None)
          if (
              previous_gpu_ids
              and len(previous_gpu_ids) > 0
              and len(previous_gpu_ids) != self.world_size
          ):
              self._iter = int(
                  self._iter * len(previous_gpu_ids) / self.world_size
              )
              self.logger.info(
                  "the iteration number is changed due to "
                  "change of GPU number"
              )
  
      # resume meta information meta
      self.meta = checkpoint["meta"]
  
      if "optimizer" in checkpoint and resume_optimizer:
          if isinstance(self.optimizer, Optimizer):
              self.optimizer.load_state_dict(checkpoint["optimizer"])
          elif isinstance(self.optimizer, dict):
              for k in self.optimizer.keys():
                  self.optimizer[k].load_state_dict(
                      checkpoint["optimizer"][k]
                  )
          else:
              raise TypeError(
                  "Optimizer should be dict or torch.optim.Optimizer "
                  f"but got {type(self.optimizer)}"
              )
  
      self.logger.info(
          "resumed epoch %d, iter %d", self.epoch, self.iter
      )
  
imports: import copy
  import logging
  import os.path
  import warnings
  from abc import ABCMeta, abstractmethod
  import torch
  from torch.optim import Optimizer
  import annotator.uniformer.mmcv
  from ..parallel import is_module_wrapper
  from .checkpoint import load_checkpoint
  from .dist_utils import get_dist_info
  from .hooks import HOOKS, Hook
  from .log_buffer import LogBuffer
  from .priority import Priority, get_priority
  from .utils import get_time_str
label_desc: Use image node_id 22 for calling the BaseRunner obj's underlying member method code with example usage: obj.resume(checkpoint, resume_optimizer, map_location) without return types