In the posted code snippet, no backward() operation is called, thus no gradients are calculated, and optimizerD.step() will use any gradients, which are already assigned to the passed parameters.
I guess. you’ve forgotten to post the code containing the backward() operation.
In that case the loss.backward() is used to calculate the gradients.