Magic Moments for Structured Output Prediction