code: def kendalltau_dist(params1, params2=None):
      r
      assert params2 is None or len(params1) == len(params2)
      ranks1 = rankdata(params1, method="ordinal")
      if params2 is None:
          ranks2 = np.arange(1, len(params1) + 1, dtype=float)
      else:
          ranks2 = rankdata(params2, method="ordinal")
      tau, _ = kendalltau(ranks1, ranks2)
      n_items = len(params1)
      n_pairs = n_items * (n_items - 1) / 2
      return round((n_pairs - n_pairs * tau) / 2)