code: def _weighted_median(y, axis=1, weights=None):
      """Calculate weighted median.
  
      Parameters
      ----------
      y : np.ndarray, pd.Series or pd.DataFrame
          Values to take the weighted median of.
      weights: np.ndarray
          Weights for each value in `array`. Must be same shape as `array` or
          of shape `(array.shape[0],)` if axis=0 or `(array.shape[1], ) if axis=1.
      axis : int
          The axis of `y` to apply the weights to.
  
      Returns
      -------
      w_median : float
          Weighted median
      """
      w_median = np.apply_along_axis(
          func1d=_weighted_percentile,
          axis=axis,
          arr=y,
          sample_weight=weights,
          percentile=50,
      )
      return w_median
  
imports: import numpy
  from sklearn.utils.stats import _weighted_percentile
  from sklearn.utils.validation import check_consistent_length
label_desc: Use image node_id 2 for calling a global function with example usage: _weighted_median(y, axis, weights) and returns: w_median