code: def build_substr_idx(umis, umi_length, min_edit):
      '''
      Build a dictionary of nearest neighbours using substrings, can be used
      to reduce the number of pairwise comparisons.
      '''
      substr_idx = collections.defaultdict(
          lambda: collections.defaultdict(set))
      slices = get_substr_slices(umi_length, min_edit + 1)
      for idx in slices:
          for u in umis:
              u_sub = u[slice(*idx)]
              substr_idx[idx][u_sub].add(u)
      return substr_idf build_substr_idx(umis, umi_length, min_edit):
      '''
      Build a dictionary of nearest neighbours using substrings, can be used
      to reduce the number of pairwise comparisons.
      '''
      substr_idx = collections.defaultdict(
          lambda: collections.defaultdict(set))
      slices = get_substr_slices(umi_length, min_edit + 1)
      for idx in slices:
          for u in umis:
              u_sub = u[slice(*idx)]
              substr_idx[idx][u_sub].add(u)
      return substr_idx
docs: Build a dictionary of nearest neighbours using substrings, can be used
      to reduce the number of pairwise comparisons.