class_docstr: CategoryFeatureGenerator is used to convert object types to category types, as well as remove rare categories and optimize memory usage.
  After fitting, previously unseen categories during transform are treated as missing values.
  
  Parameters
  ----------
  stateful_categories : bool, default True
      If True, categories from training are applied to transformed data, and any unknown categories from input data will be treated as missing values.
      It is recommended to keep this value as True to avoid strange downstream behaviour.
  minimize_memory : bool, default True
      If True, minimizes category memory usage by converting all category values to sequential integers.
      This replaces any string data present in the categories but does not alter the behavior of models when using the category as a feature so long
      as the original string values are not required downstream.
      It is recommended to keep this value as True to dramatically reduce memory usage with no cost to accuracy.
  cat_order : str, default 'original'
      Determines the order in which categories are stored.
      This is important when minimize_memory is True, as the order will determine which categories are converted to which integer values.
      Valid values:
          'original' : Keep the original order. If the feature was originally an object, this is equivalent to 'alphanumeric'.
          'alphanumeric' : Sort the categories alphanumerically.
          'count' : Sort the categories by frequency (Least frequent in front with code of 0)
  minimum_cat_count : int, default None
      The minimum number of occurrences a category must have in the training data to avoid being considered a rare category.
      Rare categories are removed and treated as missing values.
      If None, no minimum count is required. This includes categories that never occur in the data but are present in the category object
      as possible categories.
  maximum_num_cat : int, default None
      The maximum amount of categories that can be considered non-rare.
      Sorted by occurrence count, up to the N highest count categories will be kept if maximum_num_cat=N. All others will be considered rare categories.
  fillna : str, default None
      The method used to handle missing values. Only valid if stateful_categories=True.
      Missing values include the values that were originally NaN and values converted to NaN from other parameters such as minimum_cat_count.
      Valid values:
          None : Keep missing values as is. They will appear as NaN and have no category assigned to them.
          'mode' : Set missing values to the most frequent category in their feature.
  **kwargs :
      Refer to :class:`AbstractFeatureGenerator` documentation for details on valid key word arguments.
class_docstr_tok: ["CategoryFeatureGenerator","is","used","to","convert","object","types","to","category","types",",","as","well","as","remove","rare","categories","and","optimize","memory","usage",".","After","fitting",",","previously","unseen","categories","during","transform","are","treated","as","missing","values",".","Parameters","--","--","--","--","--","stateful_categories",":","bool",",","default","True","If","True",",","categories","from","training","are","applied","to","transformed","data",",","and","any","unknown","categories","from","input","data","will","be","treated","as","missing","values",".","It","is","recommended","to","keep","this","value","as","True","to","avoid","strange","downstream","behaviour",".","minimize_memory",":","bool",",","default","True","If","True",",","minimizes","category","memory","usage","by","converting","all","category","values","to","sequential","integers",".","This","replaces","any","string","data","present","in","the","categories","but","does","not","alter","the","behavior","of","models","when","using","the","category","as","a","feature","so","long","as","the","original","string","values","are","not","required","downstream",".","It","is","recommended","to","keep","this","value","as","True","to","dramatically","reduce","memory","usage","with","no","cost","to","accuracy",".","cat_order",":","str",",","default","'original'","Determines","the","order","in","which","categories","are","stored",".","This","is","important","when","minimize_memory","is","True",",","as","the","order","will","determine","which","categories","are","converted","to","which","integer","values",".","Valid","values",":","'original","'",":","Keep","the","original","order",".","If","the","feature","was","originally","an","object",",","this","is","equivalent","to","'alphanumeric","'",".","'alphanumeric","'",":","Sort","the","categories","alphanumerically",".","'count","'",":","Sort","the","categories","by","frequency","(","Least","frequent","in","front","with","code","of","0",")","minimum_cat_count",":","int",",","default","None","The","minimum","number","of","occurrences","a","category","must","have","in","the","training","data","to","avoid","being","considered","a","rare","category",".","Rare","categories","are","removed","and","treated","as","missing","values",".","If","None",",","no","minimum","count","is","required",".","This","includes","categories","that","never","occur","in","the","data","but","are","present","in","the","category","object","as","possible","categories",".","maximum_num_cat",":","int",",","default","None","The","maximum","amount","of","categories","that","can","be","considered","non-rare",".","Sorted","by","occurrence","count",",","up","to","the","N","highest","count","categories","will","be","kept","if","maximum_num_cat=N",".","All","others","will","be","considered","rare","categories",".","fillna",":","str",",","default","None","The","method","used","to","handle","missing","values",".","Only","valid","if","stateful_categories=True",".","Missing","values","include","the","values","that","were","originally","NaN","and","values","converted","to","NaN","from","other","parameters","such","as","minimum_cat_count",".","Valid","values",":","None",":","Keep","missing","values","as","is",".","They","will","appear","as","NaN","and","have","no","category","assigned","to","them",".","'mode","'",":","Set","missing","values","to","the","most","frequent","category","in","their","feature",".","*","*","kwargs",":","Refer","to",":","class",":","`","AbstractFeatureGenerator","`","documentation","for","details","on","valid","key","word","arguments","."]
code: def _fit_transform(self, X: DataFrame, **kwargs) -> (DataFrame, dict):
      if self._stateful_categories:
          (
              X_out,
              self.category_map,
              self._fillna_map,
          ) = self._generate_category_map(X=X)
          if self._fillna_map is not None:
              for column in self._fillna_map:
                  X_out[column] = X_out[column].fillna(
                      self._fillna_map[column]
                  )
      else:
          X_out = self._transform(X)
      feature_metadata_out_type_group_map_special = copy.deepcopy(
          self.feature_metadata_in.type_group_map_special
      )
      if S_TEXT in feature_metadata_out_type_group_map_special:
          text_features = (
              feature_metadata_out_type_group_map_special.pop(S_TEXT)
          )
          feature_metadata_out_type_group_map_special[
              S_TEXT_AS_CATEGORY
          ] += [
              feature
              for feature in text_features
              if feature
              not in feature_metadata_out_type_group_map_special[
                  S_TEXT_AS_CATEGORY
              ]
          ]
      return X_out, feature_metadata_out_type_group_map_special
  
file_path: autogluon/features/src/autogluon/features/generators/category.py
imports: import copy
  import logging
  import pandas
  from pandas import DataFrame
  from pandas.api.types import CategoricalDtype
  from autogluon.common.features.types import R_BOOL, R_CATEGORY, R_OBJECT, S_DATETIME_AS_OBJECT, S_IMAGE_BYTEARRAY, S_IMAGE_PATH, S_TEXT, S_TEXT_AS_CATEGORY
  from .abstract import AbstractFeatureGenerator
  from .memory_minimize import CategoryMemoryMinimizeFeatureGenerator
label_desc: Use image node_id 2 for calling the CategoryFeatureGenerator obj's underlying member method code with example usage: obj._fit_transform(X) and returns: X_out,  feature_metadata_out_type_group_map_special