code: def test_partition_users_frac():
      ratings = lktu.ml_test.ratings
      splits = xf.partition_users(ratings, 5, xf.SampleFrac(0.2))
      splits = list(splits)
      assert len(splits) == 5
      ucounts = ratings.groupby("user").item.count()
      uss = ucounts * 0.2
  
      for s in splits:
          tucs = s.test.groupby("user").item.count()
          assert all(tucs >= uss.loc[tucs.index] - 1)
          assert all(tucs <= uss.loc[tucs.index] + 1)
          assert all(s.test.index.union(s.train.index) == ratings.index)
          assert len(s.test) + len(s.train) == len(ratings)
  
      # we have all users
      users = ft.reduce(
          lambda us1, us2: us1 | us2, (set(s.test.user) for s in splits)
      )
      assert len(users) == ratings.user.nunique()
      assert users == set(ratings.user)
  
imports: import itertools
  import functools
  import pytest
  import math
  import numpy
  import lenskit.util.test
  import lenskit.crossfold
label_desc: Use image node_id 12 for calling a global function with example usage: test_partition_users_frac() without return types