I haven’t done much with DICOMs but here 13 is a Dataset I made to read NIfTI files, although it was intended for segmentation not classification.  I haven’t given it a proper test as when I tried it I had a mistake with my segmentation masks, but I’m reasonably sure that was why my results were bad.
Depending on what I was trying to do I’ve used lists and dictionaries when assembling my dataset, depending on how my data was saved out.  Neither method has given me issues, but generally the training process works much, much faster and the datasets are a bit simpler if you do most of the preprocessing for your data and save it out as torch tensors beforehand (contrast above to this dataset) 4.  Doubly so if your files need normalization applied.