class_docstr: Recall-Oriented Understudy for Gisting Evaluation (ROUGE)
  
  ROUGE is a metric for measuring the quality of summaries. It is based on calculating the recall
  between ngrams in the predicted summary and a set of reference summaries. See [Lin,
  "ROUGE: A Package For Automatic Evaluation Of Summaries", 2004]
  (https://api.semanticscholar.org/CorpusID:964287).
  
  # Parameters
  
  ngram_size : `int`, optional (default = `2`)
      ROUGE scores are calculate for ROUGE-1 .. ROUGE-`ngram_size`
  exclude_indices : `Set[int]`, optional (default = `None`)
      Indices to exclude when calculating ngrams. This should usually include
      the indices of the start, end, and pad tokens.
class_docstr_tok: ["Recall-Oriented","Understudy","for","Gisting","Evaluation","(","ROUGE",")","ROUGE","is","a","metric","for","measuring","the","quality","of","summaries",".","It","is","based","on","calculating","the","recall","between","ngrams","in","the","predicted","summary","and","a","set","of","reference","summaries",".","See","[","Lin",",","''","ROUGE",":","A","Package","For","Automatic","Evaluation","Of","Summaries","''",",","2004","]","(","https",":","\/\/api.semanticscholar.org\/CorpusID:964287",")",".","#","Parameters","ngram_size",":","`","int","`",",","optional","(","default","=","`","2","`",")","ROUGE","scores","are","calculate","for","ROUGE-1","..","ROUGE-","`","ngram_size","`","exclude_indices",":","`","Set","[","int","]","`",",","optional","(","default","=","`","None","`",")","Indices","to","exclude","when","calculating","ngrams",".","This","should","usually","include","the","indices","of","the","start",",","end",",","and","pad","tokens","."]
docstr: Compute sum of F1 scores given batch of predictions and references.
docstr_tok: ["Compute","sum","of","F1","scores","given","batch","of","predictions","and","references","."]
code: def _get_rouge_l_score(
      self,
      predicted_tokens: torch.LongTensor,
      reference_tokens: torch.LongTensor,
  ) -> float:
      """
      Compute sum of F1 scores given batch of predictions and references.
      """
      total_f1 = 0.0
  
      for predicted_seq, reference_seq in zip(
          predicted_tokens, reference_tokens
      ):
          from allennlp.training.util import get_valid_tokens_mask
  
          m = (
              get_valid_tokens_mask(
                  reference_seq, self._exclude_indices
              )
              .sum()
              .item()
          )
          n = (
              get_valid_tokens_mask(
                  predicted_seq, self._exclude_indices
              )
              .sum()
              .item()
          )
  
          lcs = self._longest_common_subsequence(
              reference_seq, predicted_seq
          )
  
          # This also rules out the case that m or n are 0, so we don't worry about it later
          if lcs == 0:
              continue
  
          recall_lcs = lcs / m
          precision_lcs = lcs / n
  
          f1 = (
              2
              * recall_lcs
              * precision_lcs
              / (recall_lcs + precision_lcs)
          )
  
          total_f1 += f1
  
      return dist_reduce_sum(total_f1)
  
file_path: allennlp/allennlp/training/metrics/rouge.py
imports: from collections import defaultdict
  from typing import Tuple, Dict, Set, Optional
  import torch
  from allennlp.training.metrics.metric import Metric
  from allennlp.nn.util import dist_reduce_sum
label_desc: Use image node_id 4 for calling the ROUGE obj's underlying member method code with example usage: obj._get_rouge_l_score(predicted_tokens, reference_tokens) and returns: dist_reduce_sum