code: def jensenshannon(p, q, base=None):
      """
      Compute the Jensen-Shannon distance (metric) between
      two 1-D probability arrays. This is the square root
      of the Jensen-Shannon divergence.
  
      The Jensen-Shannon distance between two probability
      vectors `p` and `q` is defined as,
  
      .. math::
  
         \\sqrt{\\frac{D(p \\parallel m) + D(q \\parallel m)}{2}}
  
      where :math:`m` is the pointwise mean of :math:`p` and :math:`q`
      and :math:`D` is the Kullback-Leibler divergence.
  
      This routine will normalize `p` and `q` if they don't sum to 1.0.
  
      Parameters
      ----------
      p : (N,) array_like
          left probability vector
      q : (N,) array_like
          right probability vector
      base : double, optional
          the base of the logarithm used to compute the output
          if not given, then the routine uses the default base of
          scipy.stats.entropy.
  
      Returns
      -------
      js : double
          The Jensen-Shannon distance between `p` and `q`
  
      .. versionadded:: 1.2.0
  
      Examples
      --------
      >>> from scipy.spatial import distance
      >>> distance.jensenshannon([1.0, 0.0, 0.0], [0.0, 1.0, 0.0], 2.0)
      1.0
      >>> distance.jensenshannon([1.0, 0.0], [0.5, 0.5])
      0.46450140402245893
      >>> distance.jensenshannon([1.0, 0.0, 0.0], [1.0, 0.0, 0.0])
      0.0
  
      """
      p = np.asarray(p)
      q = np.asarray(q)
      p = p / np.sum(p, axis=0)
      q = q / np.sum(q, axis=0)
      m = (p + q) / 2.0
      left = rel_entr(p, m)
      right = rel_entr(q, m)
      js = np.sum(left, axis=0) + np.sum(right, axis=0)
      if base is not None:
          js /= np.log(base)
      return np.sqrt(js / 2.0)
  
imports: from __future__ import division, print_function, absolute_import
  import warnings
  import numpy
  from functools import partial
  from collections import namedtuple
  from scipy._lib.six import callable, string_types
  from scipy._lib.six import xrange
  from scipy._lib._util import _asarray_validated
  from .None import _distance_wrap
  from .None import _hausdorff
  from ..linalg import norm
  from ..special import rel_entr
label_desc: Use image node_id 33 for calling a global function with example usage: jensenshannon(p, q, base) and returns: np