text: import sklearn.metrics
  import numpy as np
  
  
  def ptsort(tu):
    return tu[0]
  
  def AUPRC(pts):
    true_labels = [int(x[1]) for x in pts]
    predicted_probs = [x[0] for x in pts]
    return sklearn.metrics.average_precision_score(true_labels, predicted_probs)
  
  def f1_score(truth, pred, average):
      return sklearn.metrics.f1_score(truth.cpu().numpy(),pred.cpu().numpy(),average=average)
  
  def accuracy(truth, pred):
      return sklearn.metrics.accuracy_score(truth.cpu().numpy(),pred.cpu().numpy())
  
  def eval_affect(truths, results, exclude_zero=True):
      test_preds = results.cpu().numpy()
      test_truth = truths.cpu().numpy()
  
      non_zeros = np.array([i for i, e in enumerate(test_truth) if e != 0 or (not exclude_zero)])
  
      binary_truth = (test_truth[non_zeros] > 0)
      binary_preds = (test_preds[non_zeros] > 0)
  
      return sklearn.metrics.accuracy_score(binary_truth, binary_preds)
  
  