parameters: (p, q)
return_statement: return fun(p, q)
docstring: r"""
      Compute Kullback-Leibler divergence :math:`KL(p \| q)` between two distributions.
  
      .. math::
  
          KL(p \| q) = \int p(x) \log\frac {p(x)} {q(x)} \,dx
  
      Args:
          p (Distribution): A :class:`~torch.distributions.Distribution` object.
          q (Distribution): A :class:`~torch.distributions.Distribution` object.
  
      Returns:
          Tensor: A batch of KL divergences of shape `batch_shape`.
  
      Raises:
          NotImplementedError: If the distribution types have not been registered via
              :meth:`register_kl`.
docstring_summary: r"""
      Compute Kullback-Leibler divergence :math:`KL(p \| q)` between two distributions.
docstring_tokens: r Compute Kullback - Leibler divergence : math : KL ( p \ | q ) between two distributions .
function: def kl_divergence(p, q):
      r"""
      Compute Kullback-Leibler divergence :math:`KL(p \| q)` between two distributions.
  
      .. math::
  
          KL(p \| q) = \int p(x) \log\frac {p(x)} {q(x)} \,dx
  
      Args:
          p (Distribution): A :class:`~torch.distributions.Distribution` object.
          q (Distribution): A :class:`~torch.distributions.Distribution` object.
  
      Returns:
          Tensor: A batch of KL divergences of shape `batch_shape`.
  
      Raises:
          NotImplementedError: If the distribution types have not been registered via
              :meth:`register_kl`.
      """
      try:
          fun = _KL_MEMOIZE[type(p), type(q)]
      except KeyError:
          fun = _dispatch_kl(type(p), type(q))
          _KL_MEMOIZE[type(p), type(q)] = fun
      if fun is NotImplemented:
          raise NotImplementedError
      return fun(p, q)
function_tokens: def kl_divergence ( p , q ) : try : fun = _KL_MEMOIZE [ type ( p ) , type ( q ) ] except KeyError : fun = _dispatch_kl ( type ( p ) , type ( q ) ) _KL_MEMOIZE [ type ( p ) , type ( q ) ] = fun if fun is NotImplemented : raise NotImplementedError return fun ( p , q )