Undirected Graphical Models as Approximate Posteriors