I am still confused as computing the product  (dLval/dparams) * Z_T is a forward mode AD computation on the model.
If you wanted to do that you would have to use backward of backward trick in pytorch.
Or compute the full Jacobian of the mode, but that is going to be expensive and expected to be.