Similar to varying spatial sizes in images, you could try to resize the DICOM volume.
However, since you are dealing with medical images, the resampling might not be straightforward.
@christianperone might have a good idea as the author of MedicalTorch 2. I couldn’t find a resampling method for the z-dimension, but I might have missed it while skimming through the code.
The last time I had to resample a DICOM image I used ITK for it, but I assume there should be easier methods by now.