code: def _edit_distance(
      prediction_tokens: List[str], reference_tokens: List[str]
  ) -> int:
      """Dynamic programming algorithm to compute the edit distance.
  
      Args:
          prediction_tokens: A tokenized predicted sentence
          reference_tokens: A tokenized reference sentence
      Returns:
          Edit distance between the predicted sentence and the reference sentence
  
      """
      dp = [
          [0] * (len(reference_tokens) + 1)
          for _ in range(len(prediction_tokens) + 1)
      ]
      for i in range(len(prediction_tokens) + 1):
          dp[i][0] = i
      for j in range(len(reference_tokens) + 1):
          dp[0][j] = j
      for i in range(1, len(prediction_tokens) + 1):
          for j in range(1, len(reference_tokens) + 1):
              if prediction_tokens[i - 1] == reference_tokens[j - 1]:
                  dp[i][j] = dp[i - 1][j - 1]
              else:
                  dp[i][j] = (
                      min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])
                      + 1
                  )
      return dp[-1][-1]
  
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 a global function with example usage: _edit_distance(prediction_tokens, reference_tokens) and returns: dp