Composing Graphical Models with Neural Networks for Structured Representations and Fast Inference