docstr: Fits the encoder according to X and y.
  
  Parameters
  ----------
  
  X : array-like, shape = [n_samples, n_features]
      Training vectors, where n_samples is the number of samples
      and n_features is the number of features.
  y : array-like, shape = [n_samples]
      Target values.
  
  Returns
  -------
  
  self : encoder
      Returns self.
docstr_tok: ["Fits","the","encoder","according","to","X","and","y.","Parameters","--","--","--","--","--","X",":","array-like",",","shape","=","[","n_samples",",","n_features","]","Training","vectors",",","where","n_samples","is","the","number","of","samples","and","n_features","is","the","number","of","features",".","y",":","array-like",",","shape","=","[","n_samples","]","Target","values",".","Returns","--","--","--","-","self",":","encoder","Returns","self","."]
code: def fit(self, X, y=None, **kwargs):
      """Fits the encoder according to X and y.
  
      Parameters
      ----------
  
      X : array-like, shape = [n_samples, n_features]
          Training vectors, where n_samples is the number of samples
          and n_features is the number of features.
      y : array-like, shape = [n_samples]
          Target values.
  
      Returns
      -------
  
      self : encoder
          Returns self.
  
      """
      X, y = convert_inputs(X, y)
      self._check_fit_inputs(X, y)
      self.feature_names_in_ = X.columns.tolist()
      self.n_features_in_ = len(self.feature_names_in_)
  
      if self._get_tags().get("supervised_encoder"):
          if not is_numeric_dtype(y):
              self.lab_encoder_ = LabelEncoder()
              y = self.lab_encoder_.fit_transform(y)
          else:
              self.lab_encoder_ = None
  
      self._dim = X.shape[1]
      self._determine_fit_columns(X)
  
      if not set(self.cols).issubset(X.columns):
          raise ValueError(
              "X does not contain the columns listed in cols"
          )
  
      if self.handle_missing == "error":
          if X[self.cols].isna().any().any():
              raise ValueError(
                  "Columns to be encoded can not contain null"
              )
  
      self._fit(X, y, **kwargs)
  
      # for finding invariant columns transform without y (as is done on the test set)
      X_transformed = self.transform(X, override_return_df=True)
      self.feature_names_out_ = X_transformed.columns.tolist()
  
      # drop all output columns with 0 variance.
      if self.drop_invariant:
          generated_cols = get_generated_cols(
              X, X_transformed, self.cols
          )
          self.invariant_cols = [
              x
              for x in generated_cols
              if X_transformed[x].var() <= self.INVARIANCE_THRESHOLD
          ]
          self.feature_names_out_ = [
              x
              for x in self.feature_names_out_
              if x not in self.invariant_cols
          ]
  
      return self
  
imports: from abc import abstractmethod
  from enum import Enum, auto
  import warnings
  import pandas
  import numpy
  import sklearn.base
  from pandas.api.types import is_object_dtype, is_string_dtype, is_numeric_dtype
  from pandas.core.dtypes.dtypes import CategoricalDtype
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.exceptions import NotFittedError
  from typing import Dict, List, Optional, Union
  from scipy.sparse import csr_matrix
  from sklearn.preprocessing import LabelEncoder
label_desc: Use image node_id 2 for calling the BaseEncoder obj's underlying member method code with example usage: obj.fit(X, y) and returns: self