Semantic Loss Functions for Neuro-Symbolic Structured Prediction