If your dataset is small and fits into your RAM, you might pre-load it of course and store the images in e.g. a list.
Note however, that his approach would add a startup latency, since you are loading all the files before the training can begin.
The lazy loading approach is used for larger datasets, which don’t fir into your memory or if you want to avoid the startup latency.
Also note, that you would have to transform the tensors to PIL.Images and back to tensors in case you are storing the inputs as tensors.