def _split_text_into_n_parts(n, text, output_dir):
    """
    Splits text into `n` approximately equal parts.
    The splitting is permformed only at paragraphs' boundaries.
    """
    l = len(text) // n

    texts = []

    cur_part_start = 0
    for i in range(len(text)):
        if i >= cur_part_start + l and text[i] == text[i+1] == '\n':
            texts.append(text[cur_part_start:i+2])
            cur_part_start = i + 2

    texts.append(text[cur_part_start:])

    return texts