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: Computes the longest common subsequences between `seq_1` and `seq_2`, ignoring `self._exclude_indices`.
docstr_tok: ["Computes","the","longest","common","subsequences","between","`","seq_1","`","and","`","seq_2","`",",","ignoring","`","self._exclude_indices","`","."]
code: def _longest_common_subsequence(
      self, seq_1: torch.LongTensor, seq_2: torch.LongTensor
  ):
      """
      Computes the longest common subsequences between `seq_1` and `seq_2`, ignoring `self._exclude_indices`.
      """
      m = len(seq_1)
      n = len(seq_2)
  
      # Slightly lower memory usage by iterating over the longer sequence in outer loop
      # and storing previous lcs for the shorter sequence
      if m < n:
          seq_1, seq_2 = seq_2, seq_1
          m, n = n, m
  
      prev_lcs = torch.zeros(n + 1, dtype=torch.long)
  
      for i in range(m - 1, -1, -1):
          # Make sure we don't count special tokens as part of the subsequences
          if seq_1[i].item() in self._exclude_indices:
              continue
  
          cur_lcs = torch.zeros_like(prev_lcs)
          for j in range(n - 1, -1, -1):
              if seq_1[i] == seq_2[j]:
                  cur_lcs[j] = 1 + prev_lcs[j + 1]
              else:
                  cur_lcs[j] = max(cur_lcs[j + 1], prev_lcs[j])
          prev_lcs = cur_lcs
  
      return prev_lcs[0].item()
  
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 3 for calling the ROUGE obj's underlying member method code with example usage: obj._longest_common_subsequence(seq_1, seq_2) and returns: prev_lcs