code: def spark_stratified_split(
      data,
      ratio=0.75,
      min_rating=1,
      filter_by="user",
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      seed=42,
  ):
      """Spark stratified splitter.
  
      For each user / item, the split function takes proportions of ratings which is
      specified by the split ratio(s). The split is stratified.
  
      Args:
          data (pyspark.sql.DataFrame): Spark DataFrame to be split.
          ratio (float or list): Ratio for splitting data. If it is a single float number
              it splits data into two halves and the ratio argument indicates the ratio of
              training data set; if it is a list of float numbers, the splitter splits
              data into several portions corresponding to the split ratios. If a list is
              provided and the ratios are not summed to 1, they will be normalized.
              Earlier indexed splits will have earlier times
              (e.g. the latest time per user or item in split[0] <= the earliest time per user or item in split[1])
          seed (int): Seed.
          min_rating (int): minimum number of ratings for user or item.
          filter_by (str): either "user" or "item", depending on which of the two is to filter
              with min_rating.
          col_user (str): column name of user IDs.
          col_item (str): column name of item IDs.
  
      Returns:
          list: Splits of the input data as pyspark.sql.DataFrame.
      """
      return _do_stratification_spark(
          data=data,
          ratio=ratio,
          min_rating=min_rating,
          filter_by=filter_by,
          seed=seed,
          col_user=col_user,
          col_item=col_item,
      )
  
file_path: recommenders/recommenders/datasets/spark_splitters.py
imports: import numpy
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL, DEFAULT_TIMESTAMP_COL
  from recommenders.datasets.split_utils import process_split_ratio, min_rating_filter_spark
label_desc: Use image node_id 4 for calling a global function with example usage: spark_stratified_split(data, ratio, min_rating, filter_by, col_user, col_item, seed) and returns: _do_stratification_spark