If I understand your use case correctly, your Problem object yields a batch of samples without using any index, which makes sense since you are randomly generating the data.
In that case you could check, if an IterableDataset could make more sense, which would return an iterator it its __iter__ method.