code: def find_near_matches_substitutions_ngrams(subsequence, sequence,
                                             max_substitutions):
      
      _check_arguments(subsequence, sequence, max_substitutions)
  
      match_starts = set()
      matches = []
      for match in _find_near_matches_substitutions_ngrams(subsequence, sequence,
                                                           max_substitutions):
          if match.start not in match_starts:
              match_starts.add(match.start)
              matches.append(match)
      return sorted(matches, key=lambda match: match.start)
docs: search for near-matches of subsequence in sequence
  
      This searches for near-matches, where the nearly-matching parts of the
      sequence must meet the following limitations (relative to the subsequence):
  
      * the number of character substitutions must be less than max_substitutions
      * no deletions or insertions are allowed