code: def exact_match(pred, target):
    
    res = torch.eq(target.sort(dim=1)[0], pred.sort(dim=1)[0])
    return res.prod(dim=1)
docs: Compute "Exact match" metric, also called "Subset accuracy" indicating the
    number of samples that have all their labels classified correctly.
    See https://en.wikipedia.org/wiki/Multi-label_classification
  
    :param pred: Predicted labels
    :param target: Correct labels
    :return: containing a 1 at the prediction where all labels in the prediction
             match all labels in the target