I think that might be the reason your Dataset length is smaller than the calculated predictions, since your Dataset returns the length of the data using its batch dimension.
Assuming you have 240 samples, the DataLoader will return 10 batches a 24 samples.
len(loader.dataset) will also return 240.
Now if you reshape these batches to 24*20000, your correct number of samples could be much higher, that the overall length.