code: def k_fold_splitter(
      train_data: pd.DataFrame,
      n_splits: int,
      random_state: int = None,
      stratify_column: str = None,
  ) -> SplitterReturnType:
      """
      Makes K random train/test split folds for cross validation.
      The folds are made so that every sample is used at least once for
      evaluating and K-1 times for training.
  
      If stratified is set to True, the split preserves the distribution of stratify_column
  
      Parameters
      ----------
      train_data : pandas.DataFrame
          A Pandas' DataFrame that will be split into K-Folds for cross validation.
  
      n_splits : int
          The number of folds K for the K-Fold cross validation strategy.
  
      random_state : int
          Seed to be used by the random number generator.
  
      stratify_column : string
          Column name in train_data to be used for stratified split.
      """
  
      if stratify_column is not None:
          folds = StratifiedKFold(
              n_splits=n_splits, shuffle=True, random_state=random_state
          ).split(train_data, train_data[stratify_column])
      else:
          folds = KFold(
              n_splits, shuffle=True, random_state=random_state
          ).split(train_data)
      result = list(map(lambda f: (f[0], [f[1]]), folds))
  
      logs = [
          {
              "train_size": len(fold[0]),
              "test_size": train_data.shape[0] - len(fold[0]),
          }
          for fold in result
      ]
  
      return result, logs
  
imports: import operator
  from datetime import datetime, timedelta
  from itertools import chain, repeat, starmap
  from typing import Callable, Iterable, List, Tuple, Union
  import numpy
  import pandas
  from sklearn.model_selection import GroupKFold, KFold, StratifiedKFold
  from sklearn.utils import check_random_state
  from toolz.curried import curry, partial, pipe, assoc, accumulate, map, filter
  from fklearn.common_docstrings import splitter_return_docstring
  from fklearn.types import DateType, LogType, SplitterReturnType
label_desc: Use image node_id 6 for calling a global function with example usage: k_fold_splitter(train_data, n_splits, random_state, stratify_column) and returns: result,  logs