input: Write a function to implement a k-means clustering algorithm that takes an integer k and a numpy array data as input and returns the clusters and centroids after convergence.
  assert kmeans(2, np.array([[1, 2], [3, 4], [9, 10], [11, 12]]))==([0, 0, 1, 1], np.array([[2., 3.], [10., 11.]]))
  assert kmeans(3, np.array([[1, 1], [2, 2], [9, 8], [8, 10], [10, 12]]))==([0, 0, 1, 1, 2], np.array([[1.5, 1.5], [8.5, 9.], [10., 12.]]))
  assert kmeans(1, np.array([[1, 1], [5, 5], [10, 10]]))==([0, 0, 0], np.array([[5.33333333, 5.33333333]]))
  assert kmeans(4, np.array([[1, 1], [2, 2], [3, 3], [10, 10], [20, 20], [30, 30]]))==([0, 0, 0, 1, 2, 3], np.array([[2.0, 2.0], [10.0, 10.0], [20.0, 20.0], [30.0, 30.0]]))
  assert kmeans(0, np.array([[1, 2], [3, 4], [9, 10], [11, 12]]))==(np.array([], dtype=int), np.array([]))
output: def kmeans(k, data):
      if k == 0:
          return np.array([], dtype=int), np.array([])
      
      centroids = data[np.random.choice(data.shape[0], k, replace=False)]
      while True:
          distances = np.linalg.norm(data[:, np.newaxis] - centroids, axis=2)
          clusters = np.argmin(distances, axis=1)
          new_centroids = np.array([data[clusters == i].mean(axis=0) for i in range(k)])
          
          if np.all(centroids == new_centroids):
              break
          centroids = new_centroids
      
      return clusters, centroids