I think this example refers to the case where you use the builting torch.utils.data.Dataset and torch.utils.data.Dataloader to build your dataset loader.
The dataloader in particular will give you a generator like this.