def compute_all_scores(hypotheses,
                       asqa,
                       regime='eval',
                       target_idx=0,
                       rouge_metrics=['rougeLsum'],
                       target_keys=None):
  """This function computes values of the following metrics: LENGTH, ROUGE-L, STR-EM, QA-EM, QA-F1, QA-HIT, OVERALL SCORE.

  Args:
    hypotheses: a dict of the form {"answers": {key1: answer1, key2: answer2,
      ...}
      "qa": {qa_key1: short_answer1, qa_key2: short_answer2, ...}} the first
        part of the dict ("answers") is mandatory and needs to contain predicted
        long answers to ASQA questions the second part ("qa") is option and
        needs to contain predicted short answers to disambiguated questions
    asqa: dict representation of the ASQA dataset
    regime: if "eval", then two references are used to compute ROUGE, if "train"
      then only one reference is used for ROUGE
    target_idx: specifies which of the two references to use in the train mode
    rouge_metrics: list of ROUGE metrics to compute
    target_keys: an optional set of keys. If provided, only keys from this set
      are used for evaluation

  Returns:
    All scores
  """

  if regime not in ['eval', 'train']:
    raise ValueError('Regime must be either \"train\" or \"eval\"')

  references1 = {}
  for key in asqa:
    references1[key] = asqa[key]['annotations'][
        0 if regime == 'eval' else target_idx]['long_answer']
  references2 = {
      key: asqa[key]['annotations'][1]['long_answer'] for key in asqa
  } if regime == 'eval' else None

  scores = rouge(
      hypotheses['answers'],
      references1,
      references2,
      metrics=rouge_metrics,
      target_keys=target_keys)
  scores['length'] = compute_len(hypotheses['answers'], target_keys)
  scores['str_em'] = str_em(hypotheses['answers'], asqa, target_keys)

  if 'qa' in hypotheses:
    qa_scores = score_qa_accuracy(hypotheses['qa'], asqa, target_keys)

    for m in qa_scores:
      scores[m] = qa_scores[m]

    if 'rougeLsum' not in scores:
      scores['ovscore'] = 'Undefined'
    else:
      scores['ovscore'] = np.sqrt(scores['QA-F1'] * scores['rougeLsum'])

  return scores
This function computes values of the following metrics: LENGTH, ROUGE-L, STR-EM, QA-EM, QA-F1, QA-HIT, OVERALL SCORE.

  Args:
    hypotheses: a dict of the form {"answers": {key1: answer1, key2: answer2,
      ...}
      "qa": {qa_key1: short_answer1, qa_key2: short_answer2, ...}} the first
        part of the dict ("answers") is mandatory and needs to contain predicted
        long answers to ASQA questions the second part ("qa") is option and
        needs to contain predicted short answers to disambiguated questions
    asqa: dict representation of the ASQA dataset
    regime: if "eval", then two references are used to compute ROUGE, if "train"
      then only one reference is used for ROUGE
    target_idx: specifies which of the two references to use in the train mode
    rouge_metrics: list of ROUGE metrics to compute
    target_keys: an optional set of keys. If provided, only keys from this set
      are used for evaluation

  Returns:
    All scores
  
language/asqa/scoring.py