Print training progress. Called after each epoch.

def track_progress(**context):
    """Print training progress. Called after each epoch."""
    model = context["model"]
    train_X = context["train_X"]
    dev_X = context["dev_X"]
    dev_y = context["dev_y"]
    n_train = len(train_X)
    trainer = context["trainer"]

    def each_epoch():
        global epoch_train_acc, epoch
        with model.use_params(trainer.optimizer.averages):
            avg_acc = model.evaluate_logloss(dev_X, dev_y)
        stats = (avg_acc, float(epoch_train_acc) / n_train, trainer.dropout)
        print("%.3f dev acc, %.3f train acc, %.4f drop" % stats)
        epoch_train_acc = 0.0
        epoch += 1

    return each_epoch