import torch


def get_linear_scheduler(optimizer, num_epochs, last_epoch=-1):
    """Return LambdaLR scheduler that follows a linear decay schedule."""
    def lr_lambda_func(epoch):
        """Linear decay function."""
        return 1 - epoch / num_epochs
    scheduler = torch.optim.lr_scheduler.LambdaLR(optimizer,
                                                  lr_lambda=lr_lambda_func,
                                                  last_epoch=last_epoch)
    return scheduler