def _process_corpus(net, dataset, mode='train', learning_rate=None):
    assert mode in ('train', 'test')
    counter = 0
    total_neg_log_prob = 0

    t0 = time()
    max_output_length = 0

    net.reset_state()

    for inputs, outputs, pauses in izip(dataset["inputs"], dataset["outputs"], dataset.get("pauses", [None] * dataset["total_size"])):

        if mode == 'train':
            neg_log_probs = net.train(inputs, outputs, pauses, learning_rate)
        elif mode == 'test':
            neg_log_probs = net.neg_log_prob(inputs, outputs, pauses)

        total_neg_log_prob += np.sum(neg_log_probs)
        counter += dataset["batch_size"]

        if conf.SHOW_WPS:
            elapsed_time = time() - t0
            if elapsed_time > 0:
                output = "%d%% @ %.1f wps  " % (float(counter) / dataset["total_size"] * 100,
                                                counter / elapsed_time)
                max_output_length = max(max_output_length, len(output))
                sys.stdout.write(output+"\r")
                sys.stdout.flush()
        
    if conf.SHOW_WPS:
        sys.stdout.write(" "*max_output_length+"\r")
        sys.stdout.flush()

    ppl = np.exp(counter / total_neg_log_prob)

    return ppl
dataset/ETHPy150Open ottokart/punctuator/src/trainer.py/_process_corpus/swapped operands of `/`