def METHOD_NAME(self, scheduler):
    warmup = None
    if self.warmup_iters <= 0:
        return
    if self.warmup_method == "linear":
        if scheduler and self.warmup_prefix is False:
            base_lr = self.base_lrs[0]
            if not np.isclose(self.base_lrs, base_lr).all():
                raise ValueError(
                    "The param_groups in optimizer have different warmup configs, please use different optimizers."
                )
            end_lr = scheduler.get_lr(base_lr, self.warmup_iters)
            end_factor = end_lr / base_lr
        else:
            end_factor = 1.0
        warmup = LinearLR(
            self.optimizer,
            start_factor=self.warmup_factor,
            end_factor=end_factor,
            total_iters=self.warmup_iters,
            last_step=self.last_step,
            verbose=self.verbose,
        )
    else:  # "constant"
        warmup = ConstantLR(
            self.optimizer,
            factor=self.warmup_factor,
            total_iters=self.warmup_iters,
            last_step=self.last_step,
            verbose=self.verbose,
        )
    return warmup