class_docstr: Encode categorical integer features as a one-hot numeric array.
  
  The input to this transformer should be an array-like of integers or
  strings, denoting the values taken on by categorical (discrete) features.
  The features are encoded using a one-hot (aka 'one-of-K' or 'dummy')
  encoding scheme. This creates a binary column for each category and
  returns a sparse matrix or dense array (depending on the ``sparse``
  parameter)
  
  By default, the encoder derives the categories based on the unique values
  in each feature. Alternatively, you can also specify the `categories`
  manually.
  
  Always uses handle_unknown='ignore' which maps unknown test-time categories to all zeros vector.
  
  Parameters
  ----------
  categories : 'auto' or a list of lists/arrays of values, default='auto'.
      Categories (unique values) per feature:
  
      - 'auto' : Determine categories automatically from the training data.
      - list : ``categories[i]`` holds the categories expected in the ith
        column. The passed categories should not mix strings and numeric
        values within a single feature, and should be sorted in case of
        numeric values.
  
      The used categories can be found in the ``categories_`` attribute.
  
  drop : 'first' or a list/array of shape (n_features,), default=None.
      Specifies a methodology to use to drop one of the categories per
      feature. This is useful in situations where perfectly collinear
      features cause problems, such as when feeding the resulting data
      into a neural network or an unregularized regression.
  
      - None : retain all features (the default).
      - 'first' : drop the first category in each feature. If only one
        category is present, the feature will be dropped entirely.
      - array : ``drop[i]`` is the category in feature ``X[:, i]`` that
        should be dropped. If ``drop[i]`` is an infrequent category, an
        error is raised: it is only possible to drop all of the infrequent
        categories, not just one of them.
      - 'infrequent' : drop the infrequent categories column (see
        ``max_levels`` parameter).
  
  sparse : boolean, default=True
      Will return sparse matrix if set True else will return an array.
  
  dtype : number type, default=float
      Desired dtype of output.
  
  max_levels : int, default=None
      One less than the maximum number of categories to keep (max_levels = 2 means we keep 3 distinct categories).
      Infrequent categories are grouped together and mapped into a single column, which counts as extra category.
      Unknown categories encountered at test time are mapped to all zeros vector.
  
  Attributes
  ----------
  categories_ : list of arrays
      The categories of each feature determined during fitting
      (in order of the features in X and corresponding with the output
      of ``transform``). This includes the category specified in ``drop``
      (if any).
  
  drop_idx_ : array of shape (n_features,)
      ``drop_idx_[i]`` is the index in ``categories_[i]`` of the category to
      be dropped for each feature. None if all the transformed features will
      be retained.
  
  infrequent_indices_: list of arrays of shape(n_infrequent_categories)
      ``infrequent_indices_[i]`` contains a list of indices in
      ``categories_[i]`` corresponding to the infrequent categories.
docstr: Fit OneHotEncoder to X.
  
  Parameters
  ----------
  X : array-like, shape [n_samples, n_features]
      The data to determine the categories of each feature.
  
  Returns
  -------
  self
docstr_tok: ["Fit","OneHotEncoder","to","X.","Parameters","--","--","--","--","--","X",":","array-like",",","shape","[","n_samples",",","n_features","]","The","data","to","determine","the","categories","of","each","feature",".","Returns","--","--","--","-","self"]
code: def fit(self, X, y=None):
      """Fit OneHotEncoder to X.
  
      Parameters
      ----------
      X : array-like, shape [n_samples, n_features]
          The data to determine the categories of each feature.
  
      Returns
      -------
      self
      """
      self._label_encoder = LabelEncoderFeatureGenerator(verbosity=0)
      self._cat_cols = list(X.select_dtypes(include="category").columns)
      if self._cat_cols:
          self._label_encoder.fit(X=X[self._cat_cols])
      X = self._convert_cat_to_int(X=X)
      X = np.array(
          X
      ).tolist()  # converts all elements in X to the same type (i.e. cannot mix floats, ints, and str)
      self._validate_keywords()
      self._fit(X, handle_unknown=self.handle_unknown)
      self.drop_idx_ = self._compute_drop_idx()
      # check if user wants to manually drop a feature that is
      # infrequent: this is not allowed
      if self.drop is not None and not isinstance(self.drop, str):
          for feature_idx, (infrequent_indices, drop_idx) in enumerate(
              zip(self.infrequent_indices_, self.drop_idx_)
          ):
              if drop_idx in infrequent_indices:
                  raise ValueError(
                      "Category {} of feature {} is infrequent and thus "
                      "cannot be dropped. Use drop='infrequent' "
                      "instead.".format(
                          self.categories_[feature_idx][drop_idx],
                          feature_idx,
                      )
                  )
      return self
  
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 5 for calling the OneHotMergeRaresHandleUnknownEncoder obj's underlying member method code with example usage: obj.fit(X, y) and returns: self