def elementwise_stats(knns):
  """Compute elementwise knn.

  Args:
    knns (list of dicts):
      The keys are which statistic is considered
      (e.g. 'Accuracy NSC').
      Each value should itself be a dict, whose keys
      correspond to k-NN (indexing starts at zero.)
  Returns:
    stats_dict (dict): dictionary containing information for each overlapping
      category and value of k.
  """
  stats_dict = {}
  common_keys = [set(knn.keys()) for knn in knns]
  for key in set.intersection(*common_keys):
    stats_dict[key] = {}
    common_ks = [set(knn[key].keys()) for knn in knns]
    for k in set.intersection(*common_ks):
      stats_dict[key][k] = [knn[key][k] for knn in knns]
  return stats_dict