def METHOD_NAME(text, imask):
    # it's like text.split(( |\n)), except we split the mask at the same locations too
    text_splits = []
    imask_splits = []
    split_locations = [x.start() for x in re.finditer('( |\n)', text)]
    split_locations += [len(text)]
    if len(split_locations) > 0:
        text_splits.append(text[:split_locations[0]])
        imask_splits.append(imask[:split_locations[0]])
        for i in range(1, len(split_locations)):
            text_splits.append(text[split_locations[i-1]+1:split_locations[i]])
            imask_splits.append(imask[split_locations[i-1]+1:split_locations[i]])
    else:
        text_splits = [text]
    return text_splits, imask_splits