code: def comp_joint_prob(uid2refs, uid2hyps):
      """
      Args:
          pad: padding for spliced-feature derived labels
      """
      cnts = Counter()
      skipped = []
      abs_frmdiff = 0
      for uid in uid2refs:
          if uid not in uid2hyps:
              skipped.append(uid)
              continue
          refs = uid2refs[uid]
          hyps = uid2hyps[uid]
  
          abs_frmdiff += abs(len(refs) - len(hyps))
          min_len = min(len(refs), len(hyps))
          refs = refs[:min_len]
          hyps = hyps[:min_len]
          cnts.update(zip(refs, hyps))
      tot = sum(cnts.values())
  
      ref_set = sorted({ref for ref, _ in cnts.keys()})
      hyp_set = sorted({hyp for _, hyp in cnts.keys()})
      ref2pid = dict(zip(ref_set, range(len(ref_set))))
      hyp2lid = dict(zip(hyp_set, range(len(hyp_set))))
      # print(hyp_set)
      p_xy = np.zeros((len(ref2pid), len(hyp2lid)), dtype=float)
      for (ref, hyp), cnt in cnts.items():
          p_xy[ref2pid[ref], hyp2lid[hyp]] = cnt
      p_xy /= p_xy.sum()
      return p_xy, ref2pid, hyp2lid, tot, abs_frmdiff, skipped
  
file_path: espnet/egs2/wsj/asr1/pyscripts/feats/measure_teacher_quality.py
imports: import argparse
  import re
  from collections import Counter
  import numpy
  from tabulate import tabulate
  from espnet2.utils.types import str2bool
label_desc: Use image node_id 7 for calling a global function with example usage: comp_joint_prob(uid2refs, uid2hyps) and returns: p_xy,  ref2pid,  hyp2lid,  tot,  abs_frmdiff,  skipped