class_docstr: A cudf based implementation of target encoding [1]_, which converts
  one or multiple categorical variables, 'Xs', with the average of
  corresponding values of the target variable, 'Y'. The input data is
  grouped by the columns `Xs` and the aggregated mean value of `Y` of
  each group is calculated to replace each value of `Xs`. Several
  optimizations are applied to prevent label leakage and parallelize
  the execution.
  
  Parameters
  ----------
  n_folds : int (default=4)
      Default number of folds for fitting training data. To prevent
      label leakage in `fit`, we split data into `n_folds` and
      encode one fold using the target variables of the remaining folds.
  smooth : int or float (default=0)
      Count of samples to smooth the encoding. 0 means no smoothing.
  seed : int (default=42)
      Random seed
  split_method : {'random', 'continuous', 'interleaved'},         (default='interleaved')
      Method to split train data into `n_folds`.
      'random': random split.
      'continuous': consecutive samples are grouped into one folds.
      'interleaved': samples are assign to each fold in a round robin way.
      'customize': customize splitting by providing a `fold_ids` array
      in `fit()` or `fit_transform()` functions.
  output_type : {'cupy', 'numpy', 'auto'}, default = 'auto'
      The data type of output. If 'auto', it matches input data.
  stat : {'mean','var','median'}, default = 'mean'
      The statistic used in encoding, mean, variance or median of the
      target.
  
  References
  ----------
  .. [1] https://maxhalford.github.io/blog/target-encoding/
  
  Examples
  --------
  Converting a categorical implementation to a numerical one
  
  >>> from cudf import DataFrame, Series
  >>> from cuml.preprocessing import TargetEncoder
  >>> train = DataFrame({'category': ['a', 'b', 'b', 'a'],
  ...                    'label': [1, 0, 1, 1]})
  >>> test = DataFrame({'category': ['a', 'c', 'b', 'a']})
  
  >>> encoder = TargetEncoder()
  >>> train_encoded = encoder.fit_transform(train.category, train.label)
  >>> test_encoded = encoder.transform(test.category)
  >>> print(train_encoded)
  [1. 1. 0. 1.]
  >>> print(test_encoded)
  [1.   0.75 0.5  1.  ]
docstr: Core function of target encoding
docstr_tok: ["Core","function","of","target","encoding"]
code: def _fit_transform(self, x, y, fold_ids):
      """
      Core function of target encoding
      """
      self.output_type = self._get_output_type(x)
      cp.random.seed(self.seed)
      train = self._data_with_strings_to_cudf_dataframe(x)
      x_cols = [i for i in train.columns.tolist() if i != self.id_col]
      train[self.y_col] = self._make_y_column(y)
  
      self.n_folds = min(self.n_folds, len(train))
      train[self.fold_col] = self._make_fold_column(
          len(train), fold_ids
      )
  
      self.y_stat_val = get_stat_func(self.stat)(train[self.y_col])
      if self.stat in ["median"]:
          return self._fit_transform_for_loop(train, x_cols)
  
      self.mean = train[self.y_col].mean()
      if self.stat == "var":
          y_cols = [self.y_col, self.y_col2]
          train[self.y_col2] = self._make_y_column(y * y)
          self.mean2 = train[self.y_col2].mean()
      else:
          y_cols = [self.y_col]
  
      y_count_each_fold, y_count_all = self._groupby_agg(
          train, x_cols, op="count", y_cols=y_cols
      )
  
      y_sum_each_fold, y_sum_all = self._groupby_agg(
          train, x_cols, op="sum", y_cols=y_cols
      )
  
      """
          Note:
              encode_each_fold is used to encode train data.
              encode_all is used to encode test data.
          """
      cols = [self.fold_col] + x_cols
      encode_each_fold = self._compute_output(
          y_sum_each_fold,
          y_count_each_fold,
          cols,
          f"{self.y_col}_x",
          f"{self.y_col2}_x",
      )
      encode_all = self._compute_output(
          y_sum_all, y_count_all, x_cols, self.y_col, self.y_col2
      )
  
      self.encode_all = encode_all
  
      train = train.merge(encode_each_fold, on=cols, how="left")
      del encode_each_fold
      return self._impute_and_sort(train), train
  
imports: import warnings
  from cuml.common.exceptions import NotFittedError
  from cuml.internals.safe_imports import cpu_only_import
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 5 for calling the TargetEncoder obj's underlying member method code with example usage: obj._fit_transform(x, y, fold_ids) and returns: self,  train, self