code: def _ids_to_stats(
      ids_ref_all: np.ndarray,
      ids_stream_all: np.ndarray,
      window_sizes: np.ndarray,
  ) -> np.ndarray:
      n_bootstraps = ids_ref_all.shape[0]
      n = ids_ref_all.shape[1]
      t_max = ids_stream_all.shape[1]
      n_all = ids_ref_all.shape[-1]
      n_windows = window_sizes.shape[0]
  
      stats = np.zeros((n_bootstraps, t_max, n_windows))
  
      for b in nb.prange(n_bootstraps):
          ref_cdf_all = np.sum(ids_ref_all[b], axis=0) / n
  
          cumsums = np.zeros((t_max + 1, n_all))
          for i in range(n_all):
              cumsums[1:, i] = np.cumsum(ids_stream_all[b, :, i])
  
          for k in range(n_windows):
              ws = window_sizes[k]
              win_cdf_ref = (cumsums[ws:, :n] - cumsums[:-ws, :n]) / ws
              cdf_diffs_on_ref = np.empty_like(win_cdf_ref)
              for j in range(
                  win_cdf_ref.shape[0]
              ):  # Need to loop through as can't broadcast in njit parallel
                  cdf_diffs_on_ref[j, :] = (
                      ref_cdf_all[:n] - win_cdf_ref[j, :]
                  )
              stats[b, (ws - 1) :, k] = np.sum(
                  cdf_diffs_on_ref * cdf_diffs_on_ref, axis=-1
              )
              for t in range(ws - 1, t_max):
                  win_cdf_win = (
                      cumsums[t + 1, n + t - ws : n + t]
                      - cumsums[t + 1 - ws, n + t - ws : n + t]
                  ) / ws
                  cdf_diffs_on_win = (
                      ref_cdf_all[n + t - ws : n + t] - win_cdf_win
                  )
                  stats[b, t, k] += np.sum(
                      cdf_diffs_on_win * cdf_diffs_on_win
                  )
              stats[b, :, k] = _normalise_stats(stats[b, :, k], n, ws)
      return stats
  
imports: import numpy
  from typing import Any, Callable, List, Optional, Union
  from alibi_detect.base import DriftConfigMixin
  from alibi_detect.cd.base_online import BaseUniDriftOnline
  from alibi_detect.utils.misc import quantile
  import numba
  from tqdm import tqdm
  import warnings
label_desc: Use image node_id 2 for calling a global function with example usage: _ids_to_stats(ids_ref_all, ids_stream_all, window_sizes) and returns: stats