If each target is lazily created, you would have to iterate the Dataset or DataLoader at least once.
Depending how train_set is defined, the targets might have been loaded completely in its __init__, so you could check it. Also, a DataLoader should speed up the loop, if you increase the batch size and use multiple workers.
How long does this loop take?