def _get_raw_sari_score(source_ids, prediction_ids, list_of_targets):
  """Compute the SARI score for a single prediction and one or more targets.

  Args:
    source_ids: a list / np.array of SentencePiece IDs
    prediction_ids: a list / np.array of SentencePiece IDs
    list_of_targets: a list of target ID lists / np.arrays

  Returns:
    the SARI add and deletion raw counts
    (true positive addition tokens, false positive addition tokens,
    false negative addition tokens, true positive deletion tokens,
    false positive deletion tokens, false negative deletion tokens).
  """
  source_counts = _get_ngram_counter(source_ids, 1)
  prediction_counts = _get_ngram_counter(prediction_ids, 1)
  # All ngrams in the targets with count r/num_targets, where r is the number
  # of targets where the ngram occurs.
  weighted_target_counts = collections.Counter()
  num_nonempty_targets = 0
  for target_ids_i in list_of_targets:
    target_counts_i = _get_ngram_counter(target_ids_i, 1)
    if target_counts_i:
      weighted_target_counts += target_counts_i
      num_nonempty_targets += 1

  for gram in weighted_target_counts.keys():
    weighted_target_counts[gram] /= num_nonempty_targets

  # DEL.
  source_not_prediction_counts = source_counts - prediction_counts
  source_not_target_counts = source_counts - weighted_target_counts
  del_tp = sum(
      (source_not_prediction_counts & source_not_target_counts).values())
  del_fp = sum(source_not_prediction_counts.values()) - del_tp
  del_fn = sum(source_not_target_counts.values()) - del_tp

  # ADD.
  added_to_prediction_counts = prediction_counts - source_counts
  add_tp = sum((added_to_prediction_counts & weighted_target_counts).values())
  add_fp = sum(added_to_prediction_counts.values()) - add_tp
  add_fn = sum((weighted_target_counts - source_counts).values()) - add_tp

  return (add_tp, add_fp, add_fn, del_tp, del_fp, del_fn)
Compute the SARI score for a single prediction and one or more targets.

  Args:
    source_ids: a list / np.array of SentencePiece IDs
    prediction_ids: a list / np.array of SentencePiece IDs
    list_of_targets: a list of target ID lists / np.arrays

  Returns:
    the SARI add and deletion raw counts
    (true positive addition tokens, false positive addition tokens,
    false negative addition tokens, true positive deletion tokens,
    false positive deletion tokens, false negative deletion tokens).
  
language/decontext/eval_util.py