kl divergence implementation. also I'll definitely fix comments later