code: def kendalltau_correlation(X, rowvar=False, weighted=False):
      
  
      if rowvar:
          X = X.T
  
      _, n_features = X.shape
      rank_correlation = np.eye(n_features)
      for row in np.arange(n_features):
          for col in np.arange(1 + row, n_features):
              if weighted:
                  rank_correlation[row, col], _ = weightedtau(
                      X[:, row], X[:, col], rank=False
                  )
              else:
                  rank_correlation[row, col], _ = kendalltau(X[:, row], X[:, col])
      rank_correlation = np.triu(rank_correlation, 1) + rank_correlation.T
  
      return np.sin(rank_correlation * np.pi / 2)
docs: Computes kendall's tau correlation estimate.
      The option to use scipy.stats.weightedtau is not recommended
      as the implementation does not appear to handle ties correctly.
  
      Parameters
      ----------
      X: array-like, shape = [n_samples, n_features]
          Data matrix using which we compute the empirical
          correlation
  
      Returns
      -------
      rank_correlation
  
      References
      ----------
  
      Liu, Han, Fang; Yuan, Ming; Lafferty, John; Wasserman, Larry.
      "High-dimensional semiparametric Gaussian copula graphical models."
      Ann. Statist. 40.4 (2012): 2293-2326. doi:10.1214/12-AOS1037
  
      Barber, Rina Foygel; Kolar, Mladen.
      "ROCKET: Robust Confidence Intervals via Kendall's Tau
      for Transelliptical Graphical Models."
       arXiv:1502.07641