input: Write a python function to implement the k-means clustering algorithm.
  assert np.allclose(kmeans(np.array([[1, 2], [3, 4], [5, 6], [7, 8]]), 2)[0], np.array([[2, 3], [6, 7]]), atol=0.1)
  assert np.allclose(kmeans(np.array([[1, 1], [2, 2], [3, 3], [8, 8], [9, 9]]), 2)[0], np.array([[2, 2], [8.5, 8.5]]), atol=0.1)
  assert len(set(kmeans(np.array([[1, 2], [3, 4], [5, 6], [7, 8]]), 2)[1])) == 2
output: import numpy as np
  
  def kmeans(X, k, max_iters=100):
      np.random.seed(42)
      centroids = X[np.random.choice(len(X), k, replace=False)]
      
      for _ in range(max_iters):
          distances = np.linalg.norm(X[:, np.newaxis] - centroids, axis=2)
          labels = np.argmin(distances, axis=1)
          
          new_centroids = np.array([X[labels == i].mean(axis=0) for i in range(k)])
          
          if np.all(centroids == new_centroids):
              break
              
          centroids = new_centroids
      
      return centroids, labels