Cannot insert a Tensor that requires grad as a constant

I have given my solution in RuntimeError: Cannot insert a Tensor that requires grad as a constant - #3 by smkoop. We just need manually set all parameters required_grad = False .