code: def _weighted_percentile(array, sample_weight, percentile=50):
      """Compute the weighted ``percentile`` of ``array`` with ``sample_weight``."""
      sorted_idx = np.argsort(array)
  
      # Find index of median prediction for each sample
      weight_cdf = sample_weight[sorted_idx].cumsum()
      percentile_idx = np.searchsorted(
          weight_cdf, (percentile / 100.0) * weight_cdf[-1]
      )
      return array[sorted_idx[percentile_idx]]
  
imports: import numpy
  from scipy.stats import rankdata
  from .fixes import bincount
label_desc: Use image node_id 2 for calling a global function with example usage: _weighted_percentile(array, sample_weight, percentile) and returns: array