Create Dataloader with IDs

Hello, I am trying to create a dataloader with the following code:

data_loader = DataLoader(dataset, batch_size=1, num_workers=num_workers,

where pool_idx = pool_idx = random.sample(range(1, len(test_dataset)), pool_size)

Example of pool_idx:

[9, 6, 2, 1, 3, 5, 7, 4, 8, 0]

Is it possible to have the image + each corresponding id so when iterating through the dataset I can have access to each id?

Kind regards

How is the ID defined?
If it’s an ID of the image, you could return it in the Dataset.__getitem__ method with the data and target tensors.