Take a look at this example - https://github.com/devnag/pytorch-generative-adversarial-networks/blob/master/gan_pytorch.py 654
Basically, only tack steps on your generator optimizer when training the generator.