Modeling Latent Variable Uncertainty for Loss-based Learning