class_docstr: Non-Distributed evaluation hook.
  
  This hook will regularly perform evaluation in a given interval when
  performing in non-distributed environment.
  
  Args:
      dataloader (DataLoader): A PyTorch dataloader, whose dataset has
          implemented ``evaluate`` function.
      start (int | None, optional): Evaluation starting epoch. It enables
          evaluation before the training starts if ``start`` <= the resuming
          epoch. If None, whether to evaluate is merely decided by
          ``interval``. Default: None.
      interval (int): Evaluation interval. Default: 1.
      by_epoch (bool): Determine perform evaluation by epoch or by iteration.
          If set to True, it will perform by epoch. Otherwise, by iteration.
          Default: True.
      save_best (str, optional): If a metric is specified, it would measure
          the best checkpoint during evaluation. The information about best
          checkpoint would be saved in ``runner.meta['hook_msgs']`` to keep
          best score value and best checkpoint path, which will be also
          loaded when resume checkpoint. Options are the evaluation metrics
          on the test dataset. e.g., ``bbox_mAP``, ``segm_mAP`` for bbox
          detection and instance segmentation. ``AR@100`` for proposal
          recall. If ``save_best`` is ``auto``, the first key of the returned
          ``OrderedDict`` result will be used. Default: None.
      rule (str | None, optional): Comparison rule for best score. If set to
          None, it will infer a reasonable rule. Keys such as 'acc', 'top'
          .etc will be inferred by 'greater' rule. Keys contain 'loss' will
          be inferred by 'less' rule. Options are 'greater', 'less', None.
          Default: None.
      test_fn (callable, optional): test a model with samples from a
          dataloader, and return the test results. If ``None``, the default
          test function ``mmcv.engine.single_gpu_test`` will be used.
          (default: ``None``)
      greater_keys (List[str] | None, optional): Metric keys that will be
          inferred by 'greater' comparison rule. If ``None``,
          _default_greater_keys will be used. (default: ``None``)
      less_keys (List[str] | None, optional): Metric keys that will be
          inferred by 'less' comparison rule. If ``None``, _default_less_keys
          will be used. (default: ``None``)
      out_dir (str, optional): The root directory to save checkpoints. If not
          specified, `runner.work_dir` will be used by default. If specified,
          the `out_dir` will be the concatenation of `out_dir` and the last
          level directory of `runner.work_dir`.
          `New in version 1.3.16.`
      file_client_args (dict): Arguments to instantiate a FileClient.
          See :class:`mmcv.fileio.FileClient` for details. Default: None.
          `New in version 1.3.16.`
      **eval_kwargs: Evaluation arguments fed into the evaluate function of
          the dataset.
  
  Notes:
      If new arguments are added for EvalHook, tools/test.py,
      tools/eval_metric.py may be affected.
class_docstr_tok: ["Non-Distributed","evaluation","hook",".","This","hook","will","regularly","perform","evaluation","in","a","given","interval","when","performing","in","non-distributed","environment",".","Args",":","dataloader","(","DataLoader",")",":","A","PyTorch","dataloader",",","whose","dataset","has","implemented","``","evaluate","``","function",".","start","(","int","|","None",",","optional",")",":","Evaluation","starting","epoch",".","It","enables","evaluation","before","the","training","starts","if","``","start","``","<","=","the","resuming","epoch",".","If","None",",","whether","to","evaluate","is","merely","decided","by","``","interval","``",".","Default",":","None",".","interval","(","int",")",":","Evaluation","interval",".","Default",":","1.","by_epoch","(","bool",")",":","Determine","perform","evaluation","by","epoch","or","by","iteration",".","If","set","to","True",",","it","will","perform","by","epoch",".","Otherwise",",","by","iteration",".","Default",":","True",".","save_best","(","str",",","optional",")",":","If","a","metric","is","specified",",","it","would","measure","the","best","checkpoint","during","evaluation",".","The","information","about","best","checkpoint","would","be","saved","in","``","runner.meta","[","'hook_msgs","'","]","``","to","keep","best","score","value","and","best","checkpoint","path",",","which","will","be","also","loaded","when","resume","checkpoint",".","Options","are","the","evaluation","metrics","on","the","test","dataset",".","e.g.",",","``","bbox_mAP","``",",","``","segm_mAP","``","for","bbox","detection","and","instance","segmentation",".","``","AR","@","100","``","for","proposal","recall",".","If","``","save_best","``","is","``","auto","``",",","the","first","key","of","the","returned","``","OrderedDict","``","result","will","be","used",".","Default",":","None",".","rule","(","str","|","None",",","optional",")",":","Comparison","rule","for","best","score",".","If","set","to","None",",","it","will","infer","a","reasonable","rule",".","Keys","such","as","'acc","'",",","'top'",".etc","will","be","inferred","by","'greater","'","rule",".","Keys","contain","'loss","'","will","be","inferred","by","'less","'","rule",".","Options","are","'greater","'",",","'less","'",",","None",".","Default",":","None",".","test_fn","(","callable",",","optional",")",":","test","a","model","with","samples","from","a","dataloader",",","and","return","the","test","results",".","If","``","None","``",",","the","default","test","function","``","mmcv.engine.single_gpu_test","``","will","be","used",".","(","default",":","``","None","``",")","greater_keys","(","List","[","str","]","|","None",",","optional",")",":","Metric","keys","that","will","be","inferred","by","'greater","'","comparison","rule",".","If","``","None","``",",","_default_greater_keys","will","be","used",".","(","default",":","``","None","``",")","less_keys","(","List","[","str","]","|","None",",","optional",")",":","Metric","keys","that","will","be","inferred","by","'less","'","comparison","rule",".","If","``","None","``",",","_default_less_keys","will","be","used",".","(","default",":","``","None","``",")","out_dir","(","str",",","optional",")",":","The","root","directory","to","save","checkpoints",".","If","not","specified",",","`","runner.work_dir","`","will","be","used","by","default",".","If","specified",",","the","`","out_dir","`","will","be","the","concatenation","of","`","out_dir","`","and","the","last","level","directory","of","`","runner.work_dir","`",".","`","New","in","version","1.3.16.","`","file_client_args","(","dict",")",":","Arguments","to","instantiate","a","FileClient",".","See",":","class",":","`","mmcv.fileio.FileClient","`","for","details",".","Default",":","None",".","`","New","in","version","1.3.16.","`","*","*","eval_kwargs",":","Evaluation","arguments","fed","into","the","evaluate","function","of","the","dataset",".","Notes",":","If","new","arguments","are","added","for","EvalHook",",","tools\/test.py",",","tools\/eval_metric.py","may","be","affected","."]
code: def before_run(self, runner):
      if not self.out_dir:
          self.out_dir = runner.work_dir
  
      self.file_client = FileClient.infer_client(
          self.file_client_args, self.out_dir
      )
  
      # if `self.out_dir` is not equal to `runner.work_dir`, it means that
      # `self.out_dir` is set so the final `self.out_dir` is the
      # concatenation of `self.out_dir` and the last level directory of
      # `runner.work_dir`
      if self.out_dir != runner.work_dir:
          basename = osp.basename(runner.work_dir.rstrip(osp.sep))
          self.out_dir = self.file_client.join_path(
              self.out_dir, basename
          )
          runner.logger.info(
              (
                  f"The best checkpoint will be saved to {self.out_dir} by "
                  f"{self.file_client.name}"
              )
          )
  
      if self.save_best is not None:
          if runner.meta is None:
              warnings.warn(
                  "runner.meta is None. Creating an empty one."
              )
              runner.meta = dict()
          runner.meta.setdefault("hook_msgs", dict())
          self.best_ckpt_path = runner.meta["hook_msgs"].get(
              "best_ckpt", None
          )
  
imports: import os.path
  import warnings
  from math import inf
  import torch.distributed
  from torch.nn.modules.batchnorm import _BatchNorm
  from torch.utils.data import DataLoader
  from annotator.uniformer.mmcv.fileio import FileClient
  from annotator.uniformer.mmcv.utils import is_seq_of
  from .hook import Hook
  from .logger import LoggerHook
label_desc: Use image node_id 3 for calling the EvalHook obj's underlying member method code with example usage: obj.before_run(runner) without return types