def get_prediction_recall_metrics(labels: Array,
                                  predictions: Array) -> MetricGroups:
  """Computes metrics over precision and recall over different groups."""
  metrics = {}
  metrics.update(
      get_positives_negatives('total', labels, predictions, 0, NUM_CLASSES))
  metrics.update(
      get_positives_negatives('coarse_grained', labels, predictions,
                              COARSE_CLASSES_START, COARSE_CLASSES_END))
  metrics.update(
      get_positives_negatives('fine_grained', labels, predictions,
                              FINE_CLASSES_START, FINE_CLASSES_END))
  metrics.update(
      get_positives_negatives('ultra_fine_grained', labels, predictions,
                              ULTRA_FINE_CLASSES_START, ULTRA_FINE_CLASSES_END))
  return metrics
Computes metrics over precision and recall over different groups.
language/mentionmemory/tasks/ultra_fine_entity_typing_task.py