How to get one sample of dataset to train and to test

dataloader = datasets.CIFAR10
trainset = dataloader(root='./data', train=True, download=True, 
                                     transform=transform_train)

Now I want to get one sample of trainset to train for debugging my code ,how to write the code?

Based on your code, you should be able to get the first element by running this:

print(next(iter(trainset)))

You may find the examples on this page helpful.

Thanks a lot, maybe

torch.utils.data.Subset(testset, subset_indices)

works