input: Write a python function to implement the K-means algorithm for clustering.
  assert kmeans(np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]]), 2)[0].tolist() == [0, 0, 0, 1, 1, 1]
  assert kmeans(np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0], [5, 2]]), 3)[0].tolist() in [[0, 0, 0, 2, 2, 2, 1], [1, 1, 1, 0, 0, 0, 2], [2, 2, 2, 1, 1, 1, 0]]
  assert kmeans(np.array([[1, 2], [2, 2], [3, 2], [8, 2], [9, 2], [10, 2]]), 2)[0].tolist() == [0, 0, 0, 1, 1, 1]
output: import numpy as np
  
  def kmeans(X, k, max_iters=100):
      np.random.seed(0)
      centroids = X[np.random.choice(X.shape[0], 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 == j].mean(axis=0) for j in range(k)])
          if np.all(centroids == new_centroids):
              break
          centroids = new_centroids
      return labels, centroids