Remember that the parameters are updated through the optimizer’s step method.
When the optimiser is initialised you pass it all the parameters it will modify.
So yes, there are still some uncleared gradients in the discriminator parameters, however:
loss_G.backward()
optimizer_G.step()

Wont be affected by them, as this will only modify the parameters of the generator based on its gradients wrt loss_G.