Usually you would lazily load the samples using a Dataset and wrap it in a DataLoader to create batches, shuffle the data, use multiple workers to load each batch etc.
Have a look at the Data loading tutorial 306 for more information on how to write a custom Dataset.