code: def test_stratified_splitter(spark_dataset):
      spark_dataset = spark_dataset.dropDuplicates()
  
      splits = spark_stratified_split(
          spark_dataset,
          ratio=RATIOS[0],
          filter_by="user",
          min_rating=10,
      )
  
      assert splits[0].count() / NUM_ROWS == pytest.approx(
          RATIOS[0], TOL
      )
      assert splits[1].count() / NUM_ROWS == pytest.approx(
          1 - RATIOS[0], TOL
      )
  
      # Test if there is intersection
      assert splits[0].intersect(splits[1]).count() == 0
      splits = spark_stratified_split(
          spark_dataset.repartition(4),
          ratio=RATIOS[0],
          filter_by="user",
          min_rating=10,
      )
      assert splits[0].intersect(splits[1]).count() == 0
  
      # Test if both contains the same user list. This is because stratified split is stratified.
      users_train = (
          splits[0]
          .select(DEFAULT_USER_COL)
          .distinct()
          .rdd.map(lambda r: r[0])
          .collect()
      )
      users_test = (
          splits[1]
          .select(DEFAULT_USER_COL)
          .distinct()
          .rdd.map(lambda r: r[0])
          .collect()
      )
  
      assert set(users_train) == set(users_test)
  
      splits = spark_stratified_split(spark_dataset, ratio=RATIOS)
  
      assert splits[0].count() / NUM_ROWS == pytest.approx(
          RATIOS[0], TOL
      )
      assert splits[1].count() / NUM_ROWS == pytest.approx(
          RATIOS[1], TOL
      )
      assert splits[2].count() / NUM_ROWS == pytest.approx(
          RATIOS[2], TOL
      )
  
      # Test if there is intersection
      assert splits[0].intersect(splits[1]).count() == 0
      assert splits[0].intersect(splits[2]).count() == 0
      assert splits[1].intersect(splits[2]).count() == 0
      splits = spark_stratified_split(
          spark_dataset.repartition(9), ratio=RATIOS
      )
      assert splits[0].intersect(splits[1]).count() == 0
      assert splits[0].intersect(splits[2]).count() == 0
      assert splits[1].intersect(splits[2]).count() == 0
  
file_path: recommenders/tests/unit/recommenders/datasets/test_spark_splitter.py
imports: import pytest
  import numpy
  import pandas
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_TIMESTAMP_COL
label_desc: Use image node_id 6 for calling a global function with example usage: test_stratified_splitter(spark_dataset) without return types