Hello, since optimizer D is used to update the parameters of D, the code is then modified to
self.optimizer_D = torch.optim.Adam(self.netD.parameters(), lr=opt.lr, betas=(opt.beta1, 0.999))

Hope this helps.