code: def _mk_average(
      xs, ys, intervals, method="average", span=1, **kwargs
  ):
      """Creates smoothed averages of `ys` at the intervals given by `intervals`.
  
      Parameters
      ----------
      xs : array-like of shape (n_samples,)
          All the datapoints of a feature (represents the x-axis).
      ys : array-like of shape (n_samples,)
          All the datapoints what we'd like to predict (represents the y-axis).
      intervals : array-like of shape (n_intervals,)
          The intervals at which we'd like to get a good average value
      method : Literal["average", "normal"], default="average"
          The method that is used for smoothing, can be either `"average"` or `"normal"`.
      span : float, default=1.0
          If the method is `"average"` then this is the span around the interval that is used to determine the average
          `y`-value, if the method is `"normal"` the span becomes the value of sigma that is used for weighted averaging.
  
      Returns
      -------
      np.ndarray of shape (n_intervals,)
          An array of the same shape of `intervals` that represents the average `y`-values at those intervals.
      """
      results = np.zeros(intervals.shape)
      for idx, interval in enumerate(intervals):
          if method == "average":
              distances = 1 / (0.01 + np.abs(xs - interval))
              predicate = (xs < (interval + span)) | (
                  xs < (interval - span)
              )
          elif method == "normal":
              distances = np.exp(-((xs - interval) ** 2) / span)
              predicate = xs == xs
          else:
              raise ValueError(
                  "method needs to be either `average` or `normal`"
              )
          subset = ys[predicate]
          dist_subset = distances[predicate]
          results[idx] = np.average(subset, weights=dist_subset)
      return results
  
file_path: scikit-lego/sklego/preprocessing/intervalencoder.py
imports: from warnings import warn
  import numpy
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils import check_array, check_X_y
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 2 for calling a global function with example usage: _mk_average(xs, ys, intervals, method, span) and returns: results