code: def search(self, query, threshold=None):
          threshold = threshold if threshold is not None else self.threshold
          results = []
          for match, samegrams in self.items_sharing_ngrams(query).items():
              allgrams = (len(self.pad(query))
                          + self.length[match] - (2 * self.N) - samegrams + 2)
              similarity = self.ngram_similarity(samegrams, allgrams, self.warp)
              if similarity >= threshold:
                  results.append((match, similarity))
          results.sort(key=lambda x: x[1], reverse=True)
          return results