Empirical Risk Minimization under Approximations: Train graphical models so that approximate inference makes accurate predictions