def sequence_accuracy(prediction, target):
  """Compute a sequence accuracy.

  This follows the original evaluation in https://github.com/LauraRuis/
    gscan_seq2seq/blob/master/seq2seq/helpers.py.

  Args:
    prediction: a list of predicted tokens.
    target: a list of target tokens.

  Returns:
    The sequence accuracy.
  """
  correct = 0
  total = 0
  prediction = prediction.copy()
  target = target.copy()
  if len(prediction) < len(target):
    difference = len(target) - len(prediction)
    prediction.extend([0] * difference)
  if len(target) < len(prediction):
    difference = len(prediction) - len(target)
    target.extend([-1] * difference)
  for i, target_int in enumerate(target):
    if i >= len(prediction):
      break
    prediction_int = prediction[i]
    if prediction_int == target_int:
      correct += 1
    total += 1
  if not total:
    return 0.
  return (correct / total) * 100
Compute a sequence accuracy.

  This follows the original evaluation in https://github.com/LauraRuis/
    gscan_seq2seq/blob/master/seq2seq/helpers.py.

  Args:
    prediction: a list of predicted tokens.
    target: a list of target tokens.

  Returns:
    The sequence accuracy.
  
language/gscan/xattn_model/evaluation.py