code: def before_run(self, runner):
      # NOTE: when resuming from a checkpoint,
      # if 'initial_momentum' is not saved,
      # it will be set according to the optimizer params
      if isinstance(runner.optimizer, dict):
          self.base_momentum = {}
          for k, optim in runner.optimizer.items():
              for group in optim.param_groups:
                  if "momentum" in group.keys():
                      group.setdefault(
                          "initial_momentum", group["momentum"]
                      )
                  else:
                      group.setdefault(
                          "initial_momentum", group["betas"][0]
                      )
              _base_momentum = [
                  group["initial_momentum"]
                  for group in optim.param_groups
              ]
              self.base_momentum.update({k: _base_momentum})
      else:
          for group in runner.optimizer.param_groups:
              if "momentum" in group.keys():
                  group.setdefault(
                      "initial_momentum", group["momentum"]
                  )
              else:
                  group.setdefault(
                      "initial_momentum", group["betas"][0]
                  )
          self.base_momentum = [
              group["initial_momentum"]
              for group in runner.optimizer.param_groups
          ]
  
imports: import annotator.uniformer.mmcv
  from .hook import HOOKS, Hook
  from .lr_updater import annealing_cos, annealing_linear, format_param
label_desc: Use image node_id 6 for calling the MomentumUpdaterHook obj's underlying member method code with example usage: obj.before_run(runner) without return types