def linear_anneal(base_lr, global_step, warmup_steps, min_lr):
    """
    Linearly annealed learning rate from 0 in the first warming up epochs.

    :param base_lr: base learning rate
    :type base_lr: float
    :param global_step: global training steps
    :type global_step: int
    :param warmup_steps: number of steps for warming up
    :type warmup_steps: int
    :param min_lr: minimum learning rate
    :type min_lr: float
    :return: scheduled learning rate
    :rtype: float
    """
    lr = max(min_lr + (base_lr - min_lr) * (1.0 - global_step / warmup_steps),
             min_lr)
    return lr