docstr: Online Cramer-von Mises (CVM) data drift detector using preconfigured thresholds, which tests for
  any change in the distribution of continuous univariate data. This detector is an adaption of that
  proposed by :cite:t:`Ross2012a`.
  
  For multivariate data, the detector makes a correction similar to the Bonferroni correction used for
  the offline detector. Given :math:`d` features, the detector configures thresholds by
  targeting the :math:`1-\beta` quantile of test statistics over the simulated streams, where
  :math:`\beta = 1 - (1-(1/ERT))^{(1/d)}`. For the univariate case, this simplifies to
  :math:`\beta = 1/ERT`. At prediction time, drift is flagged if the test statistic of any feature stream
  exceed the thresholds.
  
  Note
  ----
  In the multivariate case, for the ERT to be accurately targeted the feature streams must be independent.
  
  Parameters
  ----------
  x_ref
      Data used as reference distribution.
  ert
      The expected run-time (ERT) in the absence of drift. For the univariate detectors, the ERT is defined
      as the expected run-time after the smallest window is full i.e. the run-time from t=min(windows_sizes).
  window_sizes
      window sizes for the sliding test-windows used to compute the test-statistic.
      Smaller windows focus on responding quickly to severe drift, larger windows focus on
      ability to detect slight drift.
  preprocess_fn
      Function to preprocess the data before computing the data drift metrics.
  x_ref_preprocessed
      Whether the given reference data `x_ref` has been preprocessed yet. If `x_ref_preprocessed=True`, only
      the test data `x` will be preprocessed at prediction time. If `x_ref_preprocessed=False`, the reference
      data will also be preprocessed.
  n_bootstraps
      The number of bootstrap simulations used to configure the thresholds. The larger this is the
      more accurately the desired ERT will be targeted. Should ideally be at least an order of magnitude
      larger than the ERT.
  batch_size
      The maximum number of bootstrap simulations to compute in each batch when configuring thresholds.
      A smaller batch size reduces memory requirements, but can result in a longer configuration run time.
  n_features
      Number of features used in the statistical test. No need to pass it if no preprocessing takes place.
      In case of a preprocessing step, this can also be inferred automatically but could be more
      expensive to compute.
  verbose
      Whether or not to print progress during configuration.
  input_shape
      Shape of input data.
  data_type
      Optionally specify the data type (tabular, image or time-series). Added to metadata.
docstr_tok: ["Online","Cramer-von","Mises","(","CVM",")","data","drift","detector","using","preconfigured","thresholds",",","which","tests","for","any","change","in","the","distribution","of","continuous","univariate","data",".","This","detector","is","an","adaption","of","that","proposed","by",":","cite",":","t",":","`","Ross2012a","`",".","For","multivariate","data",",","the","detector","makes","a","correction","similar","to","the","Bonferroni","correction","used","for","the","offline","detector",".","Given",":","math",":","`","d","`","features",",","the","detector","configures","thresholds","by","targeting","the",":","math",":","`","1-\\beta","`","quantile","of","test","statistics","over","the","simulated","streams",",","where",":","math",":","`","\\beta","=","1","-","(","1-","(","1\/ERT",")",")","^","{","(","1\/d",")","}","`",".","For","the","univariate","case",",","this","simplifies","to",":","math",":","`","\\beta","=","1\/ERT","`",".","At","prediction","time",",","drift","is","flagged","if","the","test","statistic","of","any","feature","stream","exceed","the","thresholds",".","Note","--","--","In","the","multivariate","case",",","for","the","ERT","to","be","accurately","targeted","the","feature","streams","must","be","independent",".","Parameters","--","--","--","--","--","x_ref","Data","used","as","reference","distribution",".","ert","The","expected","run-time","(","ERT",")","in","the","absence","of","drift",".","For","the","univariate","detectors",",","the","ERT","is","defined","as","the","expected","run-time","after","the","smallest","window","is","full","i.e",".","the","run-time","from","t=min","(","windows_sizes",")",".","window_sizes","window","sizes","for","the","sliding","test-windows","used","to","compute","the","test-statistic",".","Smaller","windows","focus","on","responding","quickly","to","severe","drift",",","larger","windows","focus","on","ability","to","detect","slight","drift",".","preprocess_fn","Function","to","preprocess","the","data","before","computing","the","data","drift","metrics",".","x_ref_preprocessed","Whether","the","given","reference","data","`","x_ref","`","has","been","preprocessed","yet",".","If","`","x_ref_preprocessed=True","`",",","only","the","test","data","`","x","`","will","be","preprocessed","at","prediction","time",".","If","`","x_ref_preprocessed=False","`",",","the","reference","data","will","also","be","preprocessed",".","n_bootstraps","The","number","of","bootstrap","simulations","used","to","configure","the","thresholds",".","The","larger","this","is","the","more","accurately","the","desired","ERT","will","be","targeted",".","Should","ideally","be","at","least","an","order","of","magnitude","larger","than","the","ERT",".","batch_size","The","maximum","number","of","bootstrap","simulations","to","compute","in","each","batch","when","configuring","thresholds",".","A","smaller","batch","size","reduces","memory","requirements",",","but","can","result","in","a","longer","configuration","run","time",".","n_features","Number","of","features","used","in","the","statistical","test",".","No","need","to","pass","it","if","no","preprocessing","takes","place",".","In","case","of","a","preprocessing","step",",","this","can","also","be","inferred","automatically","but","could","be","more","expensive","to","compute",".","verbose","Whether","or","not","to","print","progress","during","configuration",".","input_shape","Shape","of","input","data",".","data_type","Optionally","specify","the","data","type","(","tabular",",","image","or","time-series",")",".","Added","to","metadata","."]
code: def __init__(
      self,
      x_ref: Union[np.ndarray, list],
      ert: float,
      window_sizes: List[int],
      preprocess_fn: Optional[Callable] = None,
      x_ref_preprocessed: bool = False,
      n_bootstraps: int = 10000,
      batch_size: int = 64,
      n_features: Optional[int] = None,
      verbose: bool = True,
      input_shape: Optional[tuple] = None,
      data_type: Optional[str] = None,
  ) -> None:
      """
      Online Cramer-von Mises (CVM) data drift detector using preconfigured thresholds, which tests for
      any change in the distribution of continuous univariate data. This detector is an adaption of that
      proposed by :cite:t:`Ross2012a`.
  
      For multivariate data, the detector makes a correction similar to the Bonferroni correction used for
      the offline detector. Given :math:`d` features, the detector configures thresholds by
      targeting the :math:`1-\\beta` quantile of test statistics over the simulated streams, where
      :math:`\\beta = 1 - (1-(1/ERT))^{(1/d)}`. For the univariate case, this simplifies to
      :math:`\\beta = 1/ERT`. At prediction time, drift is flagged if the test statistic of any feature stream
      exceed the thresholds.
  
      Note
      ----
      In the multivariate case, for the ERT to be accurately targeted the feature streams must be independent.
  
      Parameters
      ----------
      x_ref
          Data used as reference distribution.
      ert
          The expected run-time (ERT) in the absence of drift. For the univariate detectors, the ERT is defined
          as the expected run-time after the smallest window is full i.e. the run-time from t=min(windows_sizes).
      window_sizes
          window sizes for the sliding test-windows used to compute the test-statistic.
          Smaller windows focus on responding quickly to severe drift, larger windows focus on
          ability to detect slight drift.
      preprocess_fn
          Function to preprocess the data before computing the data drift metrics.
      x_ref_preprocessed
          Whether the given reference data `x_ref` has been preprocessed yet. If `x_ref_preprocessed=True`, only
          the test data `x` will be preprocessed at prediction time. If `x_ref_preprocessed=False`, the reference
          data will also be preprocessed.
      n_bootstraps
          The number of bootstrap simulations used to configure the thresholds. The larger this is the
          more accurately the desired ERT will be targeted. Should ideally be at least an order of magnitude
          larger than the ERT.
      batch_size
          The maximum number of bootstrap simulations to compute in each batch when configuring thresholds.
          A smaller batch size reduces memory requirements, but can result in a longer configuration run time.
      n_features
          Number of features used in the statistical test. No need to pass it if no preprocessing takes place.
          In case of a preprocessing step, this can also be inferred automatically but could be more
          expensive to compute.
      verbose
          Whether or not to print progress during configuration.
      input_shape
          Shape of input data.
      data_type
          Optionally specify the data type (tabular, image or time-series). Added to metadata.
      """
      super().__init__(
          x_ref=x_ref,
          ert=ert,
          window_sizes=window_sizes,
          preprocess_fn=preprocess_fn,
          x_ref_preprocessed=x_ref_preprocessed,
          n_bootstraps=n_bootstraps,
          n_features=n_features,
          verbose=verbose,
          input_shape=input_shape,
          data_type=data_type,
      )
      # Set config
      self._set_config(locals())
  
      self.batch_size = (
          n_bootstraps if batch_size is None else batch_size
      )
  
      # Configure thresholds and initialise detector
      self._initialise_state()
      self._configure_thresholds()
      self._configure_ref()
  
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 1 to create a new CVMDriftOnline object from inherited base classes: BaseUniDriftOnline, DriftConfigMixin with example: obj = CVMDriftOnline(x_ref, ert, window_sizes, preprocess_fn, x_ref_preprocessed, n_bootstraps, batch_size, n_features, verbose, input_shape, data_type)