class_docstr: Computes the Smith-Waterman measure between two strings.
  The Smith-Waterman algorithm performs local sequence alignment;
  that is, for determining similar regions between two strings.
  Instead of looking at the total sequence, the Smith-Waterman algorithm compares
  segments of all possible lengths and optimizes the similarity measure.
  
  https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm
  https://github.com/Yomguithereal/talisman/blob/master/src/metrics/smith-waterman.js
class_docstr_tok: ["Computes","the","Smith-Waterman","measure","between","two","strings",".","The","Smith-Waterman","algorithm","performs","local","sequence","alignment",";","that","is",",","for","determining","similar","regions","between","two","strings",".","Instead","of","looking","at","the","total","sequence",",","the","Smith-Waterman","algorithm","compares","segments","of","all","possible","lengths","and","optimizes","the","similarity","measure",".","https",":","\/\/en.wikipedia.org\/wiki\/Smith","%","E2","%","80","%","93Waterman_algorithm","https",":","\/\/github.com\/Yomguithereal\/talisman\/blob\/master\/src\/metrics\/smith-waterman.js"]
code: def __call__(self, s1: Sequence[T], s2: Sequence[T]) -> float:
      if not numpy:
          raise ImportError(
              "Please, install numpy for Smith-Waterman measure"
          )
  
      s1, s2 = self._get_sequences(s1, s2)
  
      result = self.quick_answer(s1, s2)
      if result is not None:
          return result
  
      dist_mat = numpy.zeros(
          (len(s1) + 1, len(s2) + 1),
          dtype=float,
      )
      for i, sc1 in enumerate(s1, start=1):
          for j, sc2 in enumerate(s2, start=1):
              # The score for substituting the letter a[i - 1] for b[j - 1].
              # Generally low for mismatch, high for match.
              match = dist_mat[i - 1, j - 1] + self.sim_func(sc1, sc2)
              # The scores for for introducing extra letters in one of the strings
              # (or by symmetry, deleting them from the other).
              delete = dist_mat[i - 1, j] - self.gap_cost
              insert = dist_mat[i, j - 1] - self.gap_cost
              dist_mat[i, j] = max(0, match, delete, insert)
      return dist_mat[dist_mat.shape[0] - 1, dist_mat.shape[1] - 1]
  
imports: from __future__ import annotations
  from collections import defaultdict
  from itertools import zip_longest
  from typing import Any, Sequence, TypeVar
  from .base import Base, BaseSimilarity
  from .types import SimFunc, TestFunc
label_desc: Use image node_id 3 for calling the SmithWaterman obj's underlying member method code with example usage: obj.__call__(s1, s2) and returns: dist_mat, result