Thanks for the reply. What I was worried about was actually the adversarial part.  In the following part, the pixelwise loss and the loss from the discriminator is combined and backpropagation is called. Isn’t the generator also updated with the backpropagation path from the discriminator? But the gradients from the previous loop are not zeroed. I couldn’t understand thoroughly how the gradient accumulation works in this case.
        # GAN loss
        fake_B = generator(real_A)
        pred_fake = discriminator(fake_B, real_A)
        loss_GAN = criterion_GAN(pred_fake, valid)
        # Pixel-wise loss
        loss_pixel = criterion_pixelwise(fake_B, real_B)

        # Total loss
        loss_G = loss_GAN + lambda_pixel * loss_pixel

        loss_G.backward()

        optimizer_G.step()