def match_candidates_by_order(images, max_neighbors):
    """Find candidate matching pairs by sequence order."""
    print('3333333333333333333333333 in matching by order')
    if max_neighbors <= 0:
        return set()
    n = (max_neighbors + 1) // 2

    pairs = set()
    for i, image in enumerate(images):
        a = max(0, i - n)
        b = min(len(images), i + n)
        for j in range(a, b):
            if i != j:
                pairs.add(tuple(sorted((images[i], images[j]))))    
    return pairs