Thank you for the reply,
I solved the error by switching to pytorch 1.4.0.
This issue has something to do with pytorch version 1.5.0, i think as i found similar issues on github, and it was solved by switching to previous version of pytorch.
Also thank you for pointing out mistake that i made regarding backprop through generator.