input: Write a python function to implement KNN (K-Nearest Neighbors) algorithm and predict the target class for given features.
  assert (knn(np.array([[1,2],[2,3],[3,4],[4,5]]), [0,0,1,1], 2) == np.array([0, 0, 1, 1])).all()
  assert (knn(np.array([[1,2],[2,1],[3,3],[6,5]]), [0,0,1,1], 3) == np.array([0, 0, 1, 1])).all()
  assert (knn(np.array([[1,2],[2,1],[5,5],[6,7]]), [0,0,1,1], 1) == np.array([0, 0, 1, 1])).all()
output: import numpy as np
  from scipy.spatial import distance
  
  def knn(features, labels, k):
      def predict(x):
          distances = [distance.euclidean(x, point) for point in features]
          k_indices = np.argsort(distances)[:k]
          k_nearest_labels = [labels[i] for i in k_indices]
          return max(set(k_nearest_labels), key=k_nearest_labels.count)
      
      return np.array([predict(x) for x in features])