code: def test_sample_rows():
      ratings = lktu.ml_test.ratings
      splits = xf.sample_rows(ratings, partitions=5, size=1000)
      splits = list(splits)
      assert len(splits) == 5
  
      for s in splits:
          assert len(s.test) == 1000
          assert len(s.test) + len(s.train) == len(ratings)
          test_idx = s.test.set_index(["user", "item"]).index
          train_idx = s.train.set_index(["user", "item"]).index
          assert len(test_idx.intersection(train_idx)) == 0
  
      for s1, s2 in it.product(splits, splits):
          if s1 is s2:
              continue
  
          i1 = s1.test.set_index(["user", "item"]).index
          i2 = s2.test.set_index(["user", "item"]).index
          inter = i1.intersection(i2)
          assert len(inter) == 0
  
imports: import itertools
  import functools
  import pytest
  import math
  import numpy
  import lenskit.util.test
  import lenskit.crossfold
label_desc: Use image node_id 2 for calling a global function with example usage: test_sample_rows() without return types