Compute gradient of determinant function or inverse function

Calling Variable on G.data resets the loss tree. I think pytorch might throw an error if you tried that loss.

Maybe you can try the cholesky decomposition as mentioned in this post: