def get_warmup_steps(num_training_steps: int, warmup_steps: int, warmup_ratio: float) -> int:
    """
    Get number of steps used for a linear warmup.

    Args:
        num_training_steps (`int`):
            All training steps when training.
        warmup_steps (`int`):
            Warmup steps. If > 0, `warmup_ratio` will not work.
        warmup_ratio (`float`):
            Ratio of num training steps to warmup.
    Returns:
        Warmup steps.
    """
    warmup_steps = (
        warmup_steps if warmup_steps > 0 else math.ceil(
            num_training_steps * warmup_ratio)
    )
    return warmup_steps
Get number of steps used for a linear warmup.

Args:
num_training_steps (`int`):
All training steps when training.
warmup_steps (`int`):
Warmup steps. If > 0, `warmup_ratio` will not work.
warmup_ratio (`float`):
Ratio of num training steps to warmup.
Returns:
Warmup steps.
towhee/trainer/optimization/optimization.py