input: Write a function to implement a k-means clustering algorithm in Python. The function should take an integer `k` (number of clusters) and a numpy array `data` as inputs. It should return two outputs: a numpy array `clusters` indicating the cluster assignment for each data point, and a numpy array `centroids` containing the coordinates of the cluster centroids.
  assert np.array_equal(kmeans(2, np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])), (np.array([0, 0, 0, 1, 1, 1]), np.array([[1, 2], [4, 2]])))==True
  assert np.array_equal(kmeans(3, np.array([[1, 2], [10, 8], [1, 0], [25, 15], [4, 4], [4, 2]])), (np.array([0, 2, 0, 2, 1, 1]), np.array([[1, 1], [4, 3], [17.5, 11.5]])))==True
  assert np.array_equal(kmeans(1, np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])), (np.array([0, 0, 0, 0, 0, 0]), np.array([[2.5, 2]])))==True
  assert np.array_equal(kmeans(2, np.array([[1, 2], [5, 8], [1, 0], [10, 10]])), (np.array([0, 1, 0, 1]), np.array([[1, 1], [7.5, 9]])))==True
  assert np.array_equal(kmeans(3, np.array([])), (np.array([]), np.array([])))==True
output: import numpy as np
  
  def kmeans(k, data):
      if len(data) == 0:
          return np.array([]), np.array([])
      
      centroids = data[np.random.choice(data.shape[0], k, replace=False)]
      clusters = np.zeros(data.shape[0], dtype=int)
      
      while True:
          old_clusters = clusters.copy()
          
          for i, point in enumerate(data):
              distances = np.linalg.norm(centroids - point, axis=1)
              clusters[i] = np.argmin(distances)
          
          for i in range(k):
              centroids[i] = np.mean(data[clusters == i], axis=0)
          
          if np.array_equal(old_clusters, clusters):
              break
      
      return clusters, centroids