def levenshtein_2d_blocks(string, transpositions=False, flag1='\x00', flag2
    ='\x01', flag3='\x02'):
    """
    Function returning the minimal set of longest Levenshtein distance <= 2
    blocking keys of target string. Note that this method is basically a
    generalization of the `levensthein_1d_blocks` scheme.

    Args:
        string (str): Target string.
        transpositions (bool, optional): Whether to support transpositions
            like with the Damerau-Levenshtein distance. Defaults to False.

    Returns:
        tuple: Resulting blocks.

    """
    n = len(string)
    q = n % 3
    if q == 0:
        h = n // 3
        basic = flag1 + string[:h], flag2 + string[h:h * 2], flag3 + string[
            h * 2:]
        if transpositions:
            h1 = h - 1
            return basic + (flag1 + string[:h1] + string[h], flag2 + string
                [h1] + string[h + 1:h * 2], flag3 + string[h * 2 - 1] +
                string[h * 2 + 1:])
        return basic
    elif q == 2:
        h1 = n // 3
        h = h1 + 1
        return flag1 + string[:h], flag2 + string[h:h * 2], flag3 + string[
            h * 2:], flag1 + string[:h1], flag2 + string[h1:h + h1
            ], flag3 + string[h + h1:], flag2 + string[h:h + h1]
    elif q == 1:
        h1 = n // 3
        h = h1 + 1
        return flag1 + string[:h], flag2 + string[h:h + h1], flag3 + string[
            h + h1:], flag1 + string[:h1], flag2 + string[h1:h1 + h
            ], flag2 + string[h1:h1 * 2], flag3 + string[h1 * 2:]
