Learning in Integer Latent Variable Models with Nested Automatic Differentiation