def evaluate(val_fn, batch_size, num_to_test, x_test=None, y_test=None,
    dataflow=None):
    """Evaluate the original ANN.

    Can use either numpy arrays ``x_test, y_test`` containing the test samples,
    or generate them with a dataflow
    (``Keras.ImageDataGenerator.flow_from_directory`` object).

    Parameters
    ----------

    val_fn:
        Function to evaluate model.

    batch_size: int
        Batch size

    num_to_test: int
        Number of samples to test

    x_test: Optional[np.ndarray]

    y_test: Optional[np.ndarray]

    dataflow: keras.ImageDataGenerator.flow_from_directory
    """
    err = 0
    loss = 0
    batches = int(len(x_test) / batch_size) if x_test is not None else int(
        num_to_test / batch_size)
    for i in range(batches):
        if x_test is not None:
            x_batch = x_test[i * batch_size:(i + 1) * batch_size]
            y_batch = y_test[i * batch_size:(i + 1) * batch_size]
        else:
            x_batch, y_batch = dataflow.next()
        new_loss, new_err = val_fn(x_batch, y_batch)
        err += new_err
        loss += new_loss
    err /= batches
    loss /= batches
    acc = 1 - err
    print('Test loss: {:.2f}'.format(loss))
    print('Test accuracy: {:.2%}\n'.format(acc))
    return acc
