The gradients will be calculated by
errD_real.backward()
errD_fake.backward()

not by errD, as .backward() is never used on it in the code snippet.
I guess errD is just used to print the sum of the real and fake loss for the discriminator.