The encoder predicts a distribution in latent space, a sample is drawn through a differentiable reparameterization, and the decoder reconstructs the input. Its loss balances reconstruction quality with a regularizer that shapes the latent distribution.