A Credit Assignment Compiler for Joint Prediction