def _aggregate_subset_scores(
    subset: List[Score], suffix: str
) -> Dict[str, float]:
  """Computes the average of each metric over the provided subset.

  Note that BLEURT and Query Similarity will be skipped if any of the values are
  None. This should only happen when a checkpoint/path is not provided.

  Args:
    subset: Subset of scores to compute metrics over.
    suffix: Suffix to append to this subset in the final metrics dictionary.

  Returns:
    Dictionary of metric names to metric values.
  """
  metrics = {}
  length = float(len(subset))
  if not length:
    return metrics
  metrics[f"len_{suffix}"] = length
  metrics[f"rouge_{suffix}"] = sum(m.rouge_L for m in subset) / length
  metrics[f"text_f1_{suffix}"] = sum(m.rouge_1 for m in subset) / length
  if not any(m.bleurt is None for m in subset):
    metrics[f"bleurt_{suffix}"] = sum(m.bleurt for m in subset) / length
  if not any(m.qsim is None for m in subset):
    metrics[f"qsim_{suffix}"] = sum(float(m.qsim) for m in subset) / length
  return metrics
Computes the average of each metric over the provided subset.

  Note that BLEURT and Query Similarity will be skipped if any of the values are
  None. This should only happen when a checkpoint/path is not provided.

  Args:
    subset: Subset of scores to compute metrics over.
    suffix: Suffix to append to this subset in the final metrics dictionary.

  Returns:
    Dictionary of metric names to metric values.
  
language/diffqg/metrics.py