code: def _edit_distance_helper(
      s1: np.ndarray, s2: np.ndarray, similarity_mat: np.ndarray
  ) -> float:
      l1, l2 = len(s1), len(s2)
      distance_grid = np.zeros((l1 + 1, l2 + 1))
      distance_grid[:, 0] = np.arange(l1 + 1)
      distance_grid[0, :] = np.arange(l2 + 1)
  
      for i in range(1, l1 + 1):
          for j in range(1, l2 + 1):
              if similarity_mat[i - 1, j - 1]:
                  distance_grid[i][j] = distance_grid[i - 1][j - 1]
              else:
                  distance_grid[i][j] = 1 + min(
                      distance_grid[i][j - 1],  # Remove from s1.
                      distance_grid[i - 1][j],  # Remove from s2.
                      distance_grid[i - 1][j - 1],  # Replace.
                  )
      return distance_grid[l1][l2]
  
imports: import re
  from typing import List, Optional
  import numba
  import numpy
  from nltk.tokenize.treebank import TreebankWordTokenizer
  from helm.benchmark.adaptation.request_state import RequestState
  from helm.benchmark.adaptation.adapter_spec import AdapterSpec
  from helm.benchmark.scenarios.scenario import Reference
  from helm.common.request import RequestResult
  from .metric import Metric
  from .metric_name import MetricName
  from .metric_service import MetricService
  from .statistic import Stat
label_desc: Use image node_id 2 for calling a global function with example usage: _edit_distance_helper(s1, s2, similarity_mat) and returns: distance_grid