def jensen_shannon(x, y, return_sum=False):
    """Calculate the Jensen-Shannon divergence between two distributions.

    Parameters
    ----------
    x : array-like
        Discrete probability distribution.

    y : array-like
        Discrete probability distribution.

    return_sum : bool
        Return sum of jensen shannon values.

    Returns
    -------
    jensen_shannon : float or numpy.ndarray
    """
    x, y = _check_x_y(x, y)

    m = 0.5 * (x + y)
    return 0.5 * (kullback_leibler(x, m, return_sum) +
                  kullback_leibler(y, m, return_sum))
Calculate the Jensen-Shannon divergence between two distributions.

    Parameters
    ----------
    x : array-like
        Discrete probability distribution.

    y : array-like
        Discrete probability distribution.

    return_sum : bool
        Return sum of jensen shannon values.

    Returns
    -------
    jensen_shannon : float or numpy.ndarray
    
optbinning/binning/metrics.py