from typing import Callable


def build_schedule(lr: float, final_lr: float, n_epochs: int) -> Callable:
    """
    Builds the schedule of which the learning rate decreases.
    The schedule makes the learning rate decrease linearly.

    :param lr: initial learning rate.
    :param final_lr: final learning rate.
    :param n_epochs: number of training epochs.
    :return: the schedule of the learning rate.
    """
    delta = (lr - final_lr) / n_epochs

    def schedule(epoch: int) -> float:
        assert 0 <= epoch < n_epochs
        return lr - delta * epoch
    return schedule