Learning loopy graphical models with latent variables: Efficient methods and guarantees