Here is a small dummy example:
data = torch.randn(10, 3, 224, 224)
target = torch.arange(10)

dataset = TensorDataset(data, target)
sampler = torch.utils.data.sampler.RandomSampler(
    dataset,
    replacement=True
)

loader = DataLoader(
    dataset, 
    batch_size=1,
    sampler=sampler
)

for data, target in loader:
    print(target)

Let me know, if you need more information!