code: def kl_dirichlet(q, p):
      """
      KL Divergence between two dirichlet distributions
  
      KL(q || p) = ln [gamma(q)/gamma(p)] - sum [ ln [gamma(q_j)/gamma(p_j)]
                   - (q_j - p_j) (digamma(q_j) - digamma(p_j)]
      """
      q = np.asarray(q)
      p = np.asarray(p)
      qsum = q.sum()
      psum = p.sum()
      return (
          gammaln(qsum)
          - gammaln(psum)
          - np.sum(gammaln(q) - gammaln(p))
          + np.einsum("i,i->", (q - p), (digamma(q) - digamma(qsum)))
      )
  
file_path: hmmlearn/lib/hmmlearn/_kl_divergence.py
imports: import numpy
  from scipy.special import gammaln, digamma
  from .None import _utils
label_desc: Use image node_id 1 for calling a global function with example usage: kl_dirichlet(q, p) and returns: unknown