code: def damerau_levenshtein_distance(s1, s2):
      """
      Calculates an edit distance, for typo detection. Code based on :
      https://en.wikipedia.org/wiki/Damerau–Levenshtein_distance
      """
      d = {}
      string_1_length = len(s1)
      string_2_length = len(s2)
      for i in range(-1, string_1_length + 1):
          d[(i, -1)] = i + 1
      for j in range(-1, string_2_length + 1):
          d[(-1, j)] = j + 1
  
      for i in range(string_1_length):
          for j in range(string_2_length):
              if s1[i] == s2[j]:
                  cost = 0
              else:
                  cost = 1
              d[(i, j)] = min(
                  d[(i - 1, j)] + 1,  # deletion
                  d[(i, j - 1)] + 1,  # insertion
                  d[(i - 1, j - 1)] + cost,  # substitution
              )
              if i and j and s1[i] == s2[j - 1] and s1[i - 1] == s2[j]:
                  d[(i, j)] = min(
                      d[(i, j)], d[i - 2, j - 2] + cost
                  )  # transposition
  
      return d[string_1_length - 1, string_2_length - 1]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import datetime
  import os
  import re
  from functools import partial
  import numpy
  import tensorflow
  from scipy import ndimage
  from six import string_types
label_desc: Use image node_id 12 for calling a global function with example usage: damerau_levenshtein_distance(s1, s2) and returns: d