A General Framework for Consistent Structured Prediction with Implicit Loss Embeddings