Hi,
Few things:

You can replace this to be more efficient:

diff_loss.backward()
likelihood_loss.backward()

by
(diff_loss + likelihood_loss).backward()


When you do list(foo.parameters()), you get a reference to the weights. So if you change them to not require gradients, then you basically change all your weights in your network not to require gradients. You can add .clone().detach() if you want to get a different Tensor that does not require gradients.