Well usually, the whole block between     optimizer.zero_grad() and     optimizer.step() is inside a for-loop that takes samples x from a dataset to perform the training.
So this example is missing the training loop there that would be getting the batch.