How to request data for the whole batch instead of each sample?

As the title, is it possible to request data in batches instead of request sample 1 by 1?

If you are using a Dataset and DataLoader (as explained in this tutorial), you can set the batch_size to the desired value.
On the other hand, if you are directly working with tensors, you could slice the tensors directly to create the batch.