def evaluate_one_dataset(
    LOG, dataloader, model, opt, save=True, give_return=True, epoch=0
):
    """
    Compute evaluation metrics, update LOGGER and print results.

    Args:
        LOG:         aux.LOGGER-instance. Main Logging Functionality.
        dataloader:  PyTorch Dataloader, Testdata to be evaluated.
        model:       PyTorch Network, Network to evaluate.
        opt:         argparse.Namespace, contains all training-specific parameters.
        save:        bool, if True, Checkpoints are saved when testing metrics (specifically Recall @ 1) improve.
        give_return: bool, if True, return computed metrics.
        epoch:       int, current epoch, required for logger.
    Returns:
        (optional) Computed metrics. Are normally written directly to LOG and printed.
    """
    start = time.time()
    image_paths = np.array(dataloader.dataset.image_list)

    with torch.no_grad():
        # Compute Metrics
        (
            F1,
            NMI,
            recall_at_ks,
            feature_matrix_all,
        ) = aux.eval_metrics_one_dataset(
            model, dataloader, device=opt.device, k_vals=opt.k_vals, opt=opt
        )
        # Make printable summary string.

        result_str = ", ".join(
            "@{0}: {1:.4f}".format(k, rec)
            for k, rec in zip(opt.k_vals, recall_at_ks)
        )
        result_str = "Epoch (Test) {0}: NMI [{1:.4f}] | F1 [{2:.4f}] | Recall [{3}]".format(
            epoch, NMI, F1, result_str
        )

        if LOG is not None:
            if save:
                if not len(
                    LOG.progress_saver["val"]["Recall @ 1"]
                ) or recall_at_ks[0] > np.max(
                    LOG.progress_saver["val"]["Recall @ 1"]
                ):
                    # Save Checkpoint
                    print(
                        "Set checkpoint at {}.".format(
                            LOG.prop.save_path
                            + "/checkpoint_{}.pth.tar".format(opt.iter)
                        )
                    )
                    aux.set_checkpoint(
                        model,
                        opt,
                        LOG.progress_saver,
                        LOG.prop.save_path
                        + "/checkpoint_{}.pth.tar".format(opt.iter),
                    )
                    # aux.recover_closest_one_dataset(feature_matrix_all, image_paths, LOG.prop.save_path+'/sample_recoveries.png')
            # Update logs.
            LOG.log(
                "val",
                LOG.metrics_to_log["val"],
                [epoch, np.round(time.time() - start), NMI, F1] + recall_at_ks,
            )

    print(result_str)
    if give_return:
        return recall_at_ks, NMI, F1
    else:
        None

    Compute evaluation metrics, update LOGGER and print results.

    Args:
        LOG:         aux.LOGGER-instance. Main Logging Functionality.
        dataloader:  PyTorch Dataloader, Testdata to be evaluated.
        model:       PyTorch Network, Network to evaluate.
        opt:         argparse.Namespace, contains all training-specific parameters.
        save:        bool, if True, Checkpoints are saved when testing metrics (specifically Recall @ 1) improve.
        give_return: bool, if True, return computed metrics.
        epoch:       int, current epoch, required for logger.
    Returns:
        (optional) Computed metrics. Are normally written directly to LOG and printed.
    
examples/pytorch/hilander/PSS/Smooth_AP/src/evaluate.py