code: def test_knns(u1_ml100k, pkf):
      """Ensure the k and min_k parameters are effective for knn algorithms."""
  
      # Actually, as KNNWithMeans and KNNBaseline have back up solutions for when
      # there are not enough neighbors, we can't really test them...
      klasses = (KNNBasic,)  # KNNWithMeans, KNNBaseline)
  
      k, min_k = 20, 5
      for klass in klasses:
          algo = klass(k=k, min_k=min_k)
          for trainset, testset in pkf.split(u1_ml100k):
              algo.fit(trainset)
              predictions = algo.test(testset)
              for pred in predictions:
                  if not pred.details["was_impossible"]:
                      assert min_k <= pred.details["actual_k"] <= k
  
imports: import os
  import pytest
  from surprise import accuracy, BaselineOnly, CoClustering, Dataset, KNNBaseline, KNNBasic, KNNWithMeans, KNNWithZScore, NMF, NormalPredictor, Reader, SlopeOne, SVD, SVDpp
  from surprise.model_selection import train_test_split
label_desc: Use image node_id 2 for calling a global function with example usage: test_knns(u1_ml100k, pkf) without return types