code: def bcubed(gt_labels, pred_labels):
      _check(gt_labels, pred_labels)
  
      gt_lb2idxs = _get_lb2idxs(gt_labels)
      pred_lb2idxs = _get_lb2idxs(pred_labels)
  
      num_lbs = len(gt_lb2idxs)
      pre = np.zeros(num_lbs)
      rec = np.zeros(num_lbs)
      gt_num = np.zeros(num_lbs)
  
      for i, gt_idxs in enumerate(gt_lb2idxs.values()):
          all_pred_lbs = np.unique(pred_labels[gt_idxs])
          gt_num[i] = len(gt_idxs)
          for pred_lb in all_pred_lbs:
              pred_idxs = pred_lb2idxs[pred_lb]
              n = 1.0 * np.intersect1d(gt_idxs, pred_idxs).size
              pre[i] += n**2 / len(pred_idxs)
              rec[i] += n**2 / gt_num[i]
  
      gt_num = gt_num.sum()
      avg_pre = pre.sum() / gt_num
      avg_rec = rec.sum() / gt_num
      fscore = _compute_fscore(avg_pre, avg_rec)
  
      return avg_pre, avg_rec, fscore
  
file_path: dgl/examples/pytorch/hilander/utils/metrics.py
imports: from __future__ import division
  import numpy
  from sklearn.metrics import precision_score, recall_score
  from sklearn.metrics.cluster import contingency_matrix, normalized_mutual_info_score
label_desc: Use image node_id 6 for calling a global function with example usage: bcubed(gt_labels, pred_labels) and returns: avg_pre,  avg_rec,  fscore