Fixing Implicit Derivatives: Trust-Region Based Learning of Continuous Energy Functions