A simple approach would be to use the index of the training loop and call break once you sampled the desired number of batches.
Alternatively, you could also split the Dataset using random_split and the desired length or use a sampler, but I think the first approach would be the easiest, if you just want to change the number of batches.