Latent Ewald summation for machine learning of long-range interactions