code: def test_sample_knn(nb_instances, nb_samples):
      iris = load_iris()
      X_train = iris.data
      input_shape = X_train.shape[1:]
      x = np.ones((nb_instances,) + input_shape)
  
      X_samples = _sample_knn(
          x=x, X_train=X_train, nb_samples=nb_samples
      )
  
      assert X_samples.shape[0] == nb_instances
      assert X_samples.shape[1] == nb_samples
  
file_path: alibi/alibi/confidence/tests/test_model_linearity.py
imports: import pytest
  import numpy
  from sklearn.datasets import load_iris, load_diabetes
  from sklearn.linear_model import LogisticRegression, LinearRegression
  from sklearn.svm import SVR
  from alibi.confidence.model_linearity import linearity_measure, LinearityMeasure
  from alibi.confidence.model_linearity import _linear_superposition, _sample_grid, _sample_knn
  from functools import reduce
label_desc: Use image node_id 2 for calling a global function with example usage: test_sample_knn(nb_instances, nb_samples) without return types