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","."]
docstr: Initialize rule, key_indicator, comparison_func, and best score.
  
  Here is the rule to determine which rule is used for key indicator
  when the rule is not specific (note that the key indicator matching
  is case-insensitive):
  1. If the key indicator is in ``self.greater_keys``, the rule will be
     specified as 'greater'.
  2. Or if the key indicator is in ``self.less_keys``, the rule will be
     specified as 'less'.
  3. Or if the key indicator is equal to the substring in any one item
     in ``self.greater_keys``, the rule will be specified as 'greater'.
  4. Or if the key indicator is equal to the substring in any one item
     in ``self.less_keys``, the rule will be specified as 'less'.
  
  Args:
      rule (str | None): Comparison rule for best score.
      key_indicator (str | None): Key indicator to determine the
          comparison rule.
docstr_tok: ["Initialize","rule",",","key_indicator",",","comparison_func",",","and","best","score",".","Here","is","the","rule","to","determine","which","rule","is","used","for","key","indicator","when","the","rule","is","not","specific","(","note","that","the","key","indicator","matching","is","case-insensitive",")",":","1",".","If","the","key","indicator","is","in","``","self.greater_keys","``",",","the","rule","will","be","specified","as","'greater","'",".","2",".","Or","if","the","key","indicator","is","in","``","self.less_keys","``",",","the","rule","will","be","specified","as","'less","'",".","3",".","Or","if","the","key","indicator","is","equal","to","the","substring","in","any","one","item","in","``","self.greater_keys","``",",","the","rule","will","be","specified","as","'greater","'",".","4",".","Or","if","the","key","indicator","is","equal","to","the","substring","in","any","one","item","in","``","self.less_keys","``",",","the","rule","will","be","specified","as","'less","'",".","Args",":","rule","(","str","|","None",")",":","Comparison","rule","for","best","score",".","key_indicator","(","str","|","None",")",":","Key","indicator","to","determine","the","comparison","rule","."]
code: def _init_rule(self, rule, key_indicator):
      """Initialize rule, key_indicator, comparison_func, and best score.
  
      Here is the rule to determine which rule is used for key indicator
      when the rule is not specific (note that the key indicator matching
      is case-insensitive):
      1. If the key indicator is in ``self.greater_keys``, the rule will be
         specified as 'greater'.
      2. Or if the key indicator is in ``self.less_keys``, the rule will be
         specified as 'less'.
      3. Or if the key indicator is equal to the substring in any one item
         in ``self.greater_keys``, the rule will be specified as 'greater'.
      4. Or if the key indicator is equal to the substring in any one item
         in ``self.less_keys``, the rule will be specified as 'less'.
  
      Args:
          rule (str | None): Comparison rule for best score.
          key_indicator (str | None): Key indicator to determine the
              comparison rule.
      """
      if rule not in self.rule_map and rule is not None:
          raise KeyError(
              f"rule must be greater, less or None, " f"but got {rule}."
          )
  
      if rule is None:
          if key_indicator != "auto":
              # `_lc` here means we use the lower case of keys for
              # case-insensitive matching
              key_indicator_lc = key_indicator.lower()
              greater_keys = [key.lower() for key in self.greater_keys]
              less_keys = [key.lower() for key in self.less_keys]
  
              if key_indicator_lc in greater_keys:
                  rule = "greater"
              elif key_indicator_lc in less_keys:
                  rule = "less"
              elif any(key in key_indicator_lc for key in greater_keys):
                  rule = "greater"
              elif any(key in key_indicator_lc for key in less_keys):
                  rule = "less"
              else:
                  raise ValueError(
                      f"Cannot infer the rule for key "
                      f"{key_indicator}, thus a specific rule "
                      f"must be specified."
                  )
      self.rule = rule
      self.key_indicator = key_indicator
      if self.rule is not None:
          self.compare_func = self.rule_map[self.rule]
  
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 2 for calling the EvalHook obj's underlying member method code with example usage: obj._init_rule(rule, key_indicator) without return types