class_docstr: Base class for a dynamic classifier selection (dcs) and
     dynamic ensemble selection (des) methods.
  
  All DCS and DES techniques should inherit from this class.
  
  Warning: This class should not be used directly.
  Use derived classes instead.
docstr: Prepare the DS model by setting the KNN algorithm and
  pre-processing the information required to apply the DS
  methods
  
  Parameters
  ----------
  X : array of shape (n_samples, n_features)
      The input data.
  
  y : array of shape (n_samples)
      class labels of each example in X.
  
  Returns
  -------
  self
docstr_tok: ["Prepare","the","DS","model","by","setting","the","KNN","algorithm","and","pre-processing","the","information","required","to","apply","the","DS","methods","Parameters","--","--","--","--","--","X",":","array","of","shape","(","n_samples",",","n_features",")","The","input","data",".","y",":","array","of","shape","(","n_samples",")","class","labels","of","each","example","in","X",".","Returns","--","--","--","-","self"]
code: def fit(self, X, y):
      """Prepare the DS model by setting the KNN algorithm and
      pre-processing the information required to apply the DS
      methods
  
      Parameters
      ----------
      X : array of shape (n_samples, n_features)
          The input data.
  
      y : array of shape (n_samples)
          class labels of each example in X.
  
      Returns
      -------
      self
      """
      self.random_state_ = check_random_state(self.random_state)
      X, y = self._validate_data(
          X,
          y,
          accept_sparse="csr",
          dtype=np.float64,
          order="C",
          accept_large_sparse=False,
      )
  
      # Check if the pool of classifiers is None.
      # If yes, use a BaggingClassifier for the pool.
      if self.pool_classifiers is None:
          X_dsel, y_dsel = self._fit_pool_classifiers(X, y)
      else:
          self._check_base_classifier_fitted()
          self.pool_classifiers_ = self.pool_classifiers
          X_dsel = X
          y_dsel = y
  
      self.n_classifiers_ = len(self.pool_classifiers_)
      # allow base models with feature subspaces.
      if hasattr(self.pool_classifiers_, "estimators_features_"):
          self.estimator_features_ = np.array(
              self.pool_classifiers_.estimators_features_
          )
      else:
          indices = np.arange(X.shape[1])
          self.estimator_features_ = np.tile(
              indices, (self.n_classifiers_, 1)
          )
  
      # check if the input parameters are correct.
      self._setup_label_encoder(y)
      y_dsel = self.enc_.transform(y_dsel)
      self._set_dsel(X_dsel, y_dsel)
      self._set_region_of_competence_algorithm(X_dsel)
      self._validate_parameters()
  
      self.roc_algorithm_.fit(X_dsel, y_dsel)
      self.BKS_DSEL_ = self._predict_base(self.DSEL_data_)
      self.DSEL_processed_ = self.BKS_DSEL_ == y_dsel[:, np.newaxis]
  
      return self
  
imports: import functools
  import math
  import warnings
  from abc import abstractmethod, ABCMeta
  import numpy
  from scipy.stats import mode
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.ensemble import BaseEnsemble, BaggingClassifier
  from sklearn.model_selection import train_test_split
  from sklearn.neighbors import KNeighborsClassifier
  from sklearn.preprocessing import LabelEncoder, normalize
  from sklearn.utils.validation import check_X_y, check_is_fitted, check_array, check_random_state
  from deslib.util import KNNE
  from deslib.util import faiss_knn_wrapper
  from deslib.util.dfp import frienemy_pruning_preprocessed
  from deslib.util.instance_hardness import hardness_region_competence
label_desc: Use image node_id 2 for calling the BaseDS obj's underlying member method code with example usage: obj.fit(X, y) and returns: self