input: Write a function to perform k-means clustering on data.
  assert np.allclose(kmeans(2, np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]]))[0], np.array([0, 0, 0, 1, 1, 1]))
  assert np.allclose(kmeans(3, np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]]))[1], np.array([[ 1.,  2.], [10.,  4.], [10.,  0.]]))
output: import numpy as np
  
  def kmeans(k, data, max_iters=100):
      # Randomly initialize the centroids
      centroids = data[np.random.choice(data.shape[0], k, replace=False)]
      
      for _ in range(max_iters):
          # Assign each data point to the nearest centroid
          distances = np.linalg.norm(data[:, np.newaxis] - centroids, axis=2)
          labels = np.argmin(distances, axis=1)
          
          # Calculate the new centroids
          new_centroids = np.array([data[labels == i].mean(axis=0) for i in range(k)])
          
          # Check for convergence (if centroids do not change)
          if np.all(centroids == new_centroids):
              break
          
          centroids = new_centroids
      
      return labels, centroids