code: def gaussian_kl_divergence(mean, ln_var, reduce="sum"):
      """Computes the KL-divergence of Gaussian variables from the standard one.
  
      Given two variable ``mean`` representing :math:`\\mu` and ``ln_var``
      representing :math:`\\log(\\sigma^2)`, this function calculates
      the KL-divergence in elementwise manner between the given multi-dimensional
      Gaussian :math:`N(\\mu, S)` and the standard Gaussian :math:`N(0, I)`
  
      .. math::
  
         D_{\\mathbf{KL}}(N(\\mu, S) \\| N(0, I)),
  
      where :math:`S` is a diagonal matrix such that :math:`S_{ii} = \\sigma_i^2`
      and :math:`I` is an identity matrix.
  
      The output is a variable whose value depends on the value of
      the option ``reduce``. If it is ``'no'``, it holds the elementwise
      loss values. If it is ``'sum'`` or ``'mean'``, loss values are summed up
      or averaged respectively.
  
      Args:
          mean (:class:`~chainer.Variable` or :ref:`ndarray`):
              A variable representing mean of given
              gaussian distribution, :math:`\\mu`.
          ln_var (:class:`~chainer.Variable` or :ref:`ndarray`):
              A variable representing logarithm of
              variance of given gaussian distribution, :math:`\\log(\\sigma^2)`.
          reduce (str): Reduction option. Its value must be either
              ``'sum'``, ``'mean'`` or ``'no'``. Otherwise, :class:`ValueError`
              is raised.
  
      Returns:
          ~chainer.Variable:
              A variable representing KL-divergence between
              given gaussian distribution and the standard gaussian.
              If ``reduce`` is ``'no'``, the output variable holds array
              whose shape is same as one of (hence both of) input variables.
              If it is ``'sum'`` or ``'mean'``, the output variable holds a
              scalar value.
  
      """
      if reduce not in ("sum", "mean", "no"):
          raise ValueError(
              "only 'sum', 'mean' and 'no' are valid for 'reduce', but "
              "'%s' is given" % reduce
          )
  
      var = exponential.exp(ln_var)
      mean_square = mean * mean
      loss = (mean_square + var - ln_var - 1) * 0.5
      if reduce == "sum":
          return sum.sum(loss)
      elif reduce == "mean":
          return average.average(loss)
      else:
          return loss
  
file_path: chainer/chainer/functions/loss/vae.py
imports: import math
  from chainer.functions.activation import softplus
  from chainer.functions.math import average
  from chainer.functions.math import exponential
  from chainer.functions.math import sum
label_desc: Use image node_id 1 for calling a global function with example usage: gaussian_kl_divergence(mean, ln_var, reduce) and returns: sum, average, loss