In the following code, how can I modify it such that I can iterate over x, y, and im_path for test images?
import torchvision.datasets as datasets
class MonaDataset(datasets.folder.ImageFolder):
    def __init__(self, root, transform=None, target_transform=None,
                 loader=datasets.folder.default_loader):
        super(MonaDataset, self).__init__(root, transform, target_transform, loader)

    def __getitem__(self, index):
        path, target = self.samples[index]
        sample = self.loader(path)
        if self.transform is not None:
            sample = self.transform(sample)
        if self.target_transform is not None:
            target = self.target_transform(target)
        return sample, target, path

dataset = MonaDataset('10folds/10folds_9')
print(len(dataset))
x, y, im_path = dataset[0]


print("x is: {}, y is: {}, im_path is: {}".format(x, y, im_path))

image_datasets = {x: datasets.ImageFolder(os.path.join(data_dir, x),
                                          data_transforms[x])
                  for x in ['train', 'test']}
dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=4,
                                             shuffle=True, num_workers=4)
              for x in ['train', 'test']}
dataset_sizes = {x: len(image_datasets[x]) for x in ['train', 'test']}


class_names = image_datasets['train'].classes

I need it for the following code snippet. When I am printing the class probabilities, I need to know which image do they belong to from the test folder.
nb_classes = 9

import torch.nn.functional as F

confusion_matrix = torch.zeros(nb_classes, nb_classes)

_classes = []
_preds = []
predicted_labels = []
loocv_probs = []

with torch.no_grad():
    for i, (inputs, classes) in enumerate(dataloaders['test']):
    #for i, (inputs, classes, im_path) in enumerate(dataset):
        
      
        inputs = inputs.to(device)
        tmp_labels = model_ft(inputs)
        
        classes = classes.to(device)
        classes_list = classes.cpu().detach().numpy().tolist()
        _classes[:]=[i+1 for i in classes_list]
        outputs = model_ft(inputs)
        
        gpu_tensor_probs = F.softmax(outputs, 1)
        cpu_numpy_probs = gpu_tensor_probs.data.cpu().numpy()
        loocv_probs.append(cpu_numpy_probs.tolist())
    
        _, preds = torch.max(outputs, 1)
        preds_list = preds.cpu().detach().numpy().tolist()
        _preds[:]=[i+1 for i in preds_list]
          
        predicted_labels.append(preds.cpu().detach().numpy().tolist())
        for t, p in zip(classes.view(-1), preds.view(-1)):
                confusion_matrix[t.long(), p.long()] += 1
                
print(confusion_matrix)
print(confusion_matrix.diag()/confusion_matrix.sum(1))
#print('Class probabilities:', loocv_probs)

for i in range(len(loocv_probs)): #21
    for j in range(len(loocv_probs[0])): #4
        print(*[f"{element:.2f}" for element in loocv_probs[i][j]], sep=', ', end='\n')


for i in range(9):
    print("class {:d} --> accuracy: {:.2f}, correct predictions: {:d}, all: {:d}".format(i+1, (confusion_matrix.diag()/confusion_matrix.sum(1))[i]*100, int(confusion_matrix[i][i].numpy()), int(confusion_matrix.sum(dim=1)[i].numpy())))