In sample of dcgan, it done as
optimize_D.zeros()
loss_real=compute_loss_real()
loss_real.backward()

loss_fake=compute_loss_fake()
loss_fake.backward()
optimize_D.step()


I also find another implementation likes
optimize_D.zeros()
loss_real=compute_loss_real()
loss_fake=compute_loss_fake()
loss_total=(loss_real+loss_fake) /2.0
loss_total.backward()
optimize_D.step()

Which is correct way? Do we have any benefit using the second way? My code give a small gain using the second way