input: import numpy as np 
  
  def kmeans(k, data): 
      """
      Perform k-means clustering on data
      >>> kmeans(3, np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0], [9.0, 10.0], [11.0, 12.0]]))
      (array([0, 0, 0, 1, 1, 2]), array([[2.5, 3.5], [8.0, 9.0], [11.0, 12.0]]))
      >>> kmeans(2, np.array([[1.0, 1.0], [2.0, 2.0], [4.0, 4.0], [5.0, 5.0]]))
      (array([0, 0, 1, 1]), array([[1.5, 1.5], [4.5, 4.5]]))
      """
      # randomly set initial centroids
      centroids = data[np.random.randint(low=0, high=len(data), size=k)]
      prev_centroids = np.zeros(centroids.shape)
  
      clusters = np.zeros(len(data))
      distances = np.zeros((len(data), k))
      
      # find the closest centroid for each sample
      while not np.allclose(centroids, prev_centroids):
          # save old centroids
          prev_centroids = centroids
      
          # get the distance between each point and each centroid
          for idx, centroid in enumerate(centroids):
              distances[:, idx] = np.linalg.norm(data - centroid, axis=1)
      
          # assign each sample to the closest centroids
          clusters = np.argmin(distances, axis=1)
      
          # update centroids 
          for idx in range(k):
              centroids[idx] = np.mean(data[clusters == idx], axis=0)
      
      return clusters, centroids
output:     return clusters, centroids