It sets all gradients to zero, i.e. is basically deletes all gradients from the Parameters, which were passed to the optimizer.
You need it, because the gradients won’t be cleared otherwise and thus they will be accumulated in each iteration.