The Theory and Practice of MAP Inference over Non-Convex Constraints