def _get_warmup_factor_at_iter(method: str, curr_iter: int, warmup_iters: int, warmup_factor: float) -> float:
    """Return the learning rate warmup factor at a specific iteration.

    Parameters
    ----------
    method: str
        Warmup method; either "constant" or "linear".
    curr_iter: int
        Iteration at which to calculate the warmup factor.
    warmup_iters: int
        The length of the warmup phases.
    warmup_factor: float
        The base warmup factor (the meaning changes according to the method used).

    Returns
    -------
    float: The effective warmup factor at the given iteration.
    """
    if curr_iter >= warmup_iters:
        return 1.0

    if method == "constant":
        return warmup_factor
    if method == "linear":
        alpha = curr_iter / warmup_iters
        return warmup_factor * (1 - alpha) + alpha
    raise ValueError(f"Unknown warmup method: {method}")