code: def _log_multivariate_normal_density_diag(X, means, covars):
      
      n_samples, n_dim = X.shape
      lpr = -0.5 * (n_dim * np.log(2 * np.pi) + np.sum(np.log(covars), 1)
                    + np.sum((means ** 2) / covars, 1)
                    - 2 * np.dot(X, (means / covars).T)
                    + np.dot(X ** 2, (1.0 / covars).T))
      return lpr
docs: Compute Gaussian log-density at X for a diagonal model.