class_docstr: A convenience class for calculating the Levenshtein edit distance.
  
  Class will cache some intermediate values to hasten the calculation. The implementation follows the implementation
  from https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/metrics/lib_ter.py,
  where the most of this implementation is adapted and copied from.
  
  Args:
      reference_tokens: list of reference tokens
      op_insert: cost of insertion operation
      op_delete: cost of deletion operation
      op_substitute: cost of substitution operation
class_docstr_tok: ["A","convenience","class","for","calculating","the","Levenshtein","edit","distance",".","Class","will","cache","some","intermediate","values","to","hasten","the","calculation",".","The","implementation","follows","the","implementation","from","https",":","\/\/github.com\/mjpost\/sacrebleu\/blob\/master\/sacrebleu\/metrics\/lib_ter.py",",","where","the","most","of","this","implementation","is","adapted","and","copied","from",".","Args",":","reference_tokens",":","list","of","reference","tokens","op_insert",":","cost","of","insertion","operation","op_delete",":","cost","of","deletion","operation","op_substitute",":","cost","of","substitution","operation"]
docstr: Calculate edit distance between self._words_ref and the hypothesis. Uses cache to skip some computations.
  
  Args:
      prediction_tokens: A tokenized predicted sentence.
  
  Return:
      A tuple of a calculated edit distance and a trace of executed operations.
docstr_tok: ["Calculate","edit","distance","between","self._words_ref","and","the","hypothesis",".","Uses","cache","to","skip","some","computations",".","Args",":","prediction_tokens",":","A","tokenized","predicted","sentence",".","Return",":","A","tuple","of","a","calculated","edit","distance","and","a","trace","of","executed","operations","."]
code: def __call__(
      self, prediction_tokens: List[str]
  ) -> Tuple[int, Tuple[_EditOperations, ...]]:
      """Calculate edit distance between self._words_ref and the hypothesis. Uses cache to skip some computations.
  
      Args:
          prediction_tokens: A tokenized predicted sentence.
  
      Return:
          A tuple of a calculated edit distance and a trace of executed operations.
  
      """
      # Use cached edit distance for already computed words
      start_position, cached_edit_distance = self._find_cache(
          prediction_tokens
      )
      # Calculate the rest of the edit distance matrix
      (
          edit_distance_int,
          edit_distance,
          trace,
      ) = self._levenshtein_edit_distance(
          prediction_tokens, start_position, cached_edit_distance
      )
      # Update our cache with the newly calculated rows
      self._add_cache(prediction_tokens, edit_distance)
  
      return edit_distance_int, trace
  
file_path: torchmetrics/src/torchmetrics/functional/text/helper.py
imports: import math
  from enum import Enum, unique
  from typing import Dict, List, Sequence, Tuple, Union
label_desc: Use image node_id 2 for calling the _LevenshteinEditDistance obj's underlying member method code with example usage: obj.__call__(prediction_tokens) and returns: edit_distance_int,  trace