code: def test_gridsearchcv_same_splits():
      """Ensure that all parameter combinations are tested on the same splits (we
      check their RMSE scores are the same once averaged over the splits, which
      should be enough)."""
  
      data_file = os.path.join(
          os.path.dirname(__file__), "./u1_ml100k_test"
      )
      data = Dataset.load_from_file(data_file, reader=Reader("ml-100k"))
      kf = KFold(3, shuffle=True, random_state=4)
  
      # all RMSE should be the same (as param combinations are the same)
      param_grid = {
          "n_epochs": [5],
          "lr_all": [0.2, 0.2],
          "reg_all": [0.4, 0.4],
          "n_factors": [5],
          "random_state": [0],
      }
      gs = GridSearchCV(
          SVD, param_grid, measures=["RMSE"], cv=kf, n_jobs=1
      )
      gs.fit(data)
  
      rmse_scores = [m for m in gs.cv_results["mean_test_rmse"]]
      assert (
          len(set(rmse_scores)) == 1
      )  # assert rmse_scores are all equal
  
      # Note: actually, even when setting random_state=None in kf, the same folds
      # are used because we use product(param_comb, kf.split(...)). However, it's
      # needed to have the same folds when calling fit again:
      gs.fit(data)
      rmse_scores += [m for m in gs.cv_results["mean_test_rmse"]]
      assert len(set(rmse_scores)) == 1
  
file_path: Surprise/tests/test_search.py
imports: import os
  import numpy
  import pytest
  from scipy.stats import randint, uniform
  from surprise import Dataset, Reader, SVD
  from surprise.model_selection import cross_validate, GridSearchCV, KFold, PredefinedKFold, RandomizedSearchCV
label_desc: Use image node_id 4 for calling a global function with example usage: test_gridsearchcv_same_splits() without return types