def before_train_iter(
            self,
            runner,
            batch_idx: int,
            data_batch: Optional[Union[dict, tuple, list]] = None) -> None:
        """Set the warmup value before each train iter."""
        cur_iter = runner.iter
        iters_per_epoch = runner.max_iters / runner.max_epochs
        new_val = self.ori_val * min(
            1, cur_iter / (self.warmup_epochs * iters_per_epoch))
        self.set_param(runner, new_val)
Set the warmup value before each train iter.
mmpretrain/engine/hooks/warmup_param_hook.py