Your code works for me using random data:
class MyDataset(torch.utils.data.Dataset):
    def __init__(self):
        self.datasets = [torch.arange(i+i*100, i+i*100+100) for i in range(4)]

    def __getitem__(self, idx):
        iq = int(torch.randint(0, len(self.datasets), (1,)))
        dataset = self.datasets[iq]

        data = dataset[idx]
        return data
   
    def __len__(self):
        return len(self.datasets[0])

dataset = MyDataset()
print(dataset.datasets)

loader = torch.utils.data.DataLoader(dataset, batch_size=10)
for data in loader:
    print(data)

As you can see the batch_size is used and the samples are drawn randomly from the internal datasets.