def _merge_clusters(clusters: List[List[int]], maxlen: int, columns: List[str], Lopt, plot=False) -> List[List[str]]:
    out = []
    tmp = []
    cluster_map = {}
    cluster_number = 0
    for cluster in clusters:
        if ((len(tmp) + len(cluster)) > maxlen):
            for column_name in tmp:
                cluster_map[column_name] = cluster_number
            out.append(tmp)
            tmp = []
            cluster_number += 1
        tmp.extend([columns[idx] for idx in cluster])
    if tmp:
        cluster_number += 1
        out.append(tmp)
        for column_name in tmp:
            cluster_map[column_name] = cluster_number
    if plot:
        labels = [(((x + '(') + str(cluster_map[x])) + ')') for x in columns]
        plt.figure(figsize=(25, 8))
        plt.title('Field Header Correlation Cluster Hierarchy')
        sch.dendrogram(Lopt, labels=labels, leaf_rotation=90.0)
    return out
def _merge_clusters(clusters: List[List[int]], maxlen: int, columns: List[str], Lopt, plot=False) -> List[List[str]]:
    out = []
    tmp = []
    cluster_map = {}
    cluster_number = 0
    for cluster in clusters:
        if ((len(tmp) + len(cluster)) > maxlen):
            for column_name in tmp:
                cluster_map[column_name] = cluster_number
            out.append(tmp)
            tmp = []
            cluster_number += 1
        tmp.extend([columns[idx] for idx in cluster])
    if tmp:
        cluster_number += 1
        out.append(tmp)
        for column_name in tmp:
            cluster_map[column_name] = cluster_number
    if plot:
        labels = [(((x + '(') + str(cluster_map[x])) + ')') for x in columns]
        plt.figure(figsize=(25, 8))
        plt.title('Field Header Correlation Cluster Hierarchy')
        sch.dendrogram(Lopt, labels=labels, leaf_rotation=90.0)
    return out