Thank you! I think your answer is exactly what I want. But I get an error:
criterion[1].parameters.backward(params_grad)
AttributeError: 'function' object has no attribute 'backward'

Is backward the right way to assign params_grad to the parameters in loss_module?