rime.util.assign_topk

rime.util.assign_topk(S, k, tie_breaker=1e-10, device='cpu', batch_size=None)

Return a sparse matrix where each row contains k non-zero values.

Used for both ItemRec (if S is user-by-item) and UserRec (if S is transposed). Expect the shape to align with (len(D.user_in_test), len(D.item_in_test)) or its transpose.