There are 2 things wrong with the code here. Firstly, the example you have provided does not run. Secondly, I think that you may have misunderstood how the data loader and dataset works.
The dataset class is just a class that provides access to your data. As such it needs 2 things:
a) how much data you have in the dataset, which it gets from the len method
b) how to access a data point from the dataset, which it gets from the getitem method.
Once the dataloader has the dataset and the the batch size that you need it will assemble the batch for you. I think the point that you misunderstood is that the getitem method does not need to provide the entire batch but just one element. The entire batch is assembled by the data loader automatically.