code: def test_KFold(toy_data):
      # Test n_folds parameter
      kf = KFold(n_splits=5)
      assert len(list(kf.split(toy_data))) == 5
  
      with pytest.raises(ValueError):
          kf = KFold(n_splits=10)
          next(
              kf.split(toy_data)
          )  # Too big (greater than number of ratings)
  
      with pytest.raises(ValueError):
          kf = KFold(n_splits=1)
          next(kf.split(toy_data))  # Too low (must be >= 2)
  
      # Make sure data has not been shuffled. If not shuffled, the users in the
      # testsets are 0, 1, 2... 4 (in that order).
      kf = KFold(n_splits=5, shuffle=False)
      users = [
          int(testset[0][0][-1]) for (_, testset) in kf.split(toy_data)
      ]
      assert users == list(range(5))
  
      # Make sure that when called two times without shuffling, folds are the
      # same.
      kf = KFold(n_splits=5, shuffle=False)
      testsets_a = [testset for (_, testset) in kf.split(toy_data)]
      testsets_b = [testset for (_, testset) in kf.split(toy_data)]
      assert testsets_a == testsets_b
      # test once again with another KFold instance
      kf = KFold(n_splits=5, shuffle=False)
      testsets_a = [testset for (_, testset) in kf.split(toy_data)]
      assert testsets_a == testsets_b
  
      # We'll now shuffle b and check that folds are different.
      # (this is conditioned by seed setting at the beginning of file)
      kf = KFold(n_splits=5, random_state=None, shuffle=True)
      testsets_b = [testset for (_, testset) in kf.split(toy_data)]
      assert testsets_a != testsets_b
      # test once again: two calls to kf.split make different splits when
      # random_state=None
      testsets_a = [testset for (_, testset) in kf.split(toy_data)]
      assert testsets_a != testsets_b
  
      # Make sure that folds are the same when same KFold instance is used with
      # suffle is True but random_state is set to some value
      kf = KFold(n_splits=5, random_state=1, shuffle=True)
      testsets_a = [testset for (_, testset) in kf.split(toy_data)]
      testsets_b = [testset for (_, testset) in kf.split(toy_data)]
      assert testsets_a == testsets_b
  
      # Make sure raw ratings are not shuffled by KFold
      old_raw_ratings = copy(toy_data.raw_ratings)
      kf = KFold(n_splits=5, shuffle=True)
      next(kf.split(toy_data))
      assert old_raw_ratings == toy_data.raw_ratings
  
file_path: Surprise/tests/test_split.py
imports: import os
  from collections import Counter
  from copy import copy
  import numpy
  import pytest
  from surprise import Dataset, Reader
  from surprise.model_selection import KFold, LeaveOneOut, PredefinedKFold, RepeatedKFold, ShuffleSplit, train_test_split
  from surprise.model_selection.split import get_cv
label_desc: Use image node_id 1 for calling a global function with example usage: test_KFold(toy_data) without return types