when NaN's arise all computations involving them become NaN as well, its curious your parameters turning NaN are still leading to real number losses. It might be you have a NaN catcher implemented somewhere. AFAIK it is not good practice to conceal NaN's this way as it prevents one from figuring out what is causing them in the first place.  Regardless of the other problems, I’d say this needs to be figured out, even though it may seem paradoxical that you’d want NaN's to show themselves.
While I dont know about the code in particular, I’d suggest using backward hooks, or retain_grad to look at the gradients of all the layers to figure out where NaN's first pop up. I figure NaN is basically like inf-inf, inf/inf or 0/0. As number representations are bounded, you can see all these cases, even the inf's will arise due to a division by 0 somewhere.