def kl_divergence(self, params_q, params_p):
means_q = params_q[:, :, <NUM_LIT:0>]<EOL>log_std_q = params_q[:, :, <NUM_LIT:1>]<EOL>means_p = params_p[:, :, <NUM_LIT:0>]<EOL>log_std_p = params_p[:, :, <NUM_LIT:1>]<EOL>std_q = torch.exp(log_std_q)<EOL>std_p = torch.exp(log_std_p)<EOL>kl_div = log_std_p - log_std_q + (std_q ** <NUM_LIT:2> + (means_q - means_p) ** <NUM_LIT:2>) / (<NUM_LIT> * std_p ** <NUM_LIT:2>) - <NUM_LIT:0.5><EOL>return kl_div.sum(dim=-<NUM_LIT:1>)<EOL>
Categorical distribution KL divergence calculation
KL(Q || P) = sum Q_i log (Q_i / P_i)

Formula is:
log(sigma_p) - log(sigma_q) + (sigma_q^2 + (mu_q - mu_p)^2))/(2 * sigma_p^2)