European Internet School: Generative AI: From Foundations to Advanced Applications: How Generative Models Work: Probability, Latent Space, and Training Basics