from typing import List
from typing import Tuple


def _cluster_length_to_bin(len_list: List[int], num: int) -> List[Tuple[int, int]]:
    """cluster a list of lengths into `num` buckets
    Args:
        len_list: the list of target summary lengths
        num: the number of buckets
    Returns:
        a list of tuples of which each element is the
        [lower bound, upper bound) of the bucket
    """

    avg_bin_len = len(len_list) // num
    sort_list = sorted(len_list)

    bin_bound = []

    for i in range(num):
        if i == (num - 1):
            bin_bound.append((sort_list[i * avg_bin_len], 1e5))
        else:
            bin_bound.append((sort_list[i * avg_bin_len], sort_list[(i+1) * avg_bin_len]))

    return bin_bound