def rouge_l(eval_sentences, eval_len, ref_sentences, ref_len,
            vocab, use_bpe=False):
  """Rouge-L.

  Args:
    eval_sentences: prediction to be evaluated.
    eval_len: lengths of the predictions.
    ref_sentences: reference sentences.
    ref_len: lengths of the references.
    vocab: vocabulary.
    use_bpe: to use BPE or not.

  Returns:
    Rouge-L
  """
  f1_scores = []
  for e, el, r, rl in zip(eval_sentences, eval_len, ref_sentences, ref_len):
    e = id2text(e[:el], vocab=vocab, use_bpe=use_bpe).split()
    r = r[:rl]
    r = [x for x in r if x not in SPECIAL_TOKENS]
    lcs = _len_lcs(e, r)
    f1_scores.append(_f_lcs(lcs, len(r), len(e)))
  return np.mean(f1_scores, dtype=np.float32)
Rouge-L.

  Args:
    eval_sentences: prediction to be evaluated.
    eval_len: lengths of the predictions.
    ref_sentences: reference sentences.
    ref_len: lengths of the references.
    vocab: vocabulary.
    use_bpe: to use BPE or not.

  Returns:
    Rouge-L
  
language/labs/exemplar_decoding/utils/rouge_utils.py