class_docstr: Base class for encoders that includes the code to categorize and
  transform the input features.
code: def _fit(self, X, handle_unknown="error"):
      X_list, n_samples, n_features = self._check_X(X)
  
      if self.categories != "auto":
          if len(self.categories) != n_features:
              raise ValueError(
                  "Shape mismatch: if categories is an array,"
                  " it has to be of shape (n_features,)."
              )
  
      if self.max_levels is not None:
          if (
              not isinstance(self.max_levels, Integral)
              or self.max_levels <= 0
          ):
              raise ValueError(
                  "max_levels must be None or a strictly "
                  "positive int, got {}.".format(self.max_levels)
              )
  
      self.categories_ = []
      self.infrequent_indices_ = []
  
      for i in range(n_features):
          Xi = X_list[i]
          if self.categories == "auto":
              cats = _encode(Xi)
          else:
              cats = np.array(self.categories[i], dtype=Xi.dtype)
              if Xi.dtype != object:
                  if not np.all(np.sort(cats) == cats):
                      raise ValueError(
                          "Unsorted categories are not "
                          "supported for numerical categories"
                      )
              if handle_unknown == "error":
                  diff = _encode_check_unknown(Xi, cats)
                  if diff:
                      msg = (
                          "Found unknown categories {0} in column {1}"
                          " during fit".format(diff, i)
                      )
                      raise ValueError(msg)
          self.categories_.append(cats)
  
          if self.max_levels is not None:
              infrequent_indices = (
                  self._find_infrequent_category_indices(Xi)
              )
          else:
              infrequent_indices = np.array([])
          self.infrequent_indices_.append(infrequent_indices)
  
imports: import copy
  from numbers import Integral
  import numpy
  from scipy import sparse
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from autogluon.features.generators import LabelEncoderFeatureGenerator
label_desc: Use image node_id 3 for calling the _BaseEncoder obj's underlying member method code with example usage: obj._fit(X, handle_unknown) without return types