<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fmt_confusion_matrix(hyps: Sequence[Sequence[str]], refs: Sequence[Sequence[str]], label_set: Set[str] = None, max_width: int = 25) -> str: """ Formats a confusion matrix over substitutions, ignoring insertions and deletions. """


    if not label_set:
        # Then determine the label set by reading
        raise NotImplementedError()

    alignments = [min_edit_distance_align(ref, hyp)
                  for hyp, ref in zip(hyps, refs)]

    arrow_counter = Counter() # type: Dict[Tuple[str, str], int]
    for alignment in alignments:
        arrow_counter.update(alignment)

    ref_total = Counter() # type: Dict[str, int]
    for alignment in alignments:
        ref_total.update([arrow[0] for arrow in alignment])

    labels = [label for label, count
              in sorted(ref_total.items(), key=lambda x: x[1], reverse=True)
              if label != ""][:max_width]

    format_pieces = []
    fmt = "{:3} "*(len(labels)+1)
    format_pieces.append(fmt.format(" ", *labels))
    fmt = "{:3} " + ("{:<3} " * (len(labels)))
    for ref in labels:
        # TODO
        ref_results = [arrow_counter[(ref, hyp)] for hyp in labels]
        format_pieces.append(fmt.format(ref, *ref_results))

    return "\n".join(format_pieces)