code: def estimate_entropy_kmeans(X: np.ndarray) -> float:
      """Related paper:
      Kozachenko, L., & Leonenko, N. (1987). Sample estimate of the entropy of a random vector. Problemy Peredachi
      Informatsii, 23(2), 9–16.
      """
      X = shape_into_2d(X)
  
      k = int(np.sqrt(X.shape[0]))
  
      x_neighbourhood = NearestNeighbors(n_neighbors=k + 1).fit(X)
      distances, _ = x_neighbourhood.kneighbors(X, k + 1)
      distances = distances[:, -1]
  
      sum_log_dist = np.sum(np.log(2 * distances + EPS))
  
      return (
          -digamma(k)
          + digamma(X.shape[0])
          + (X.shape[1] / float(X.shape[0])) * sum_log_dist
      )
  
file_path: dowhy/dowhy/gcm/uncertainty.py
imports: import numpy
  from numpy.linalg import det
  from scipy.special import digamma
  from scipy.stats import entropy
  from sklearn.neighbors import NearestNeighbors
  from dowhy.gcm.constant import EPS
  from dowhy.gcm.util.general import shape_into_2d
label_desc: Use image node_id 2 for calling a global function with example usage: estimate_entropy_kmeans(X) and returns: unknown