code: def kl_divergence(dist1, dist2):
      """Computes Kullback-Leibler divergence.
  
      For two continuous distributions :math:`p(x), q(x)`, it is expressed as
  
      .. math::
          D_{KL}(p||q) = \\int p(x) \\log \\frac{p(x)}{q(x)} dx
  
      For two discrete distributions :math:`p(x), q(x)`, it is expressed as
  
      .. math::
          D_{KL}(p||q) = \\sum_x p(x) \\log \\frac{p(x)}{q(x)}
  
      Args:
          dist1(:class:`~chainer.Distribution`): Distribution to calculate KL
              divergence :math:`p`. This is the first (left) operand of the KL
              divergence.
          dist2(:class:`~chainer.Distribution`): Distribution to calculate KL
              divergence :math:`q`. This is the second (right) operand of the KL
              divergence.
  
      Returns:
          ~chainer.Variable: Output variable representing kl divergence
          :math:`D_{KL}(p||q)`.
  
      Using :func:`~chainer.register_kl`, we can define behavior of
      :func:`~chainer.kl_divergence` for any two distributions.
  
      """
      return _KLDIVERGENCE[type(dist1), type(dist2)](dist1, dist2)
  
imports: import copy
  from chainer import backend
label_desc: Use image node_id 2 for calling a global function with example usage: kl_divergence(dist1, dist2) and returns: _KLDIVERGENCE