def _align_sentence_spans_for_long_sentences(original_sentence_spans, trimmed_sentence_spans):
    """Align new token spans after enforcing limits to the original locations in raw text.

    This is needed to keep track of each token's location in original document. After enforcing
    sentence limits, some sentences get split into multiple parts. The locations in original
    document don't change, but we need to maintain one list per sentence. So we regroup the spans
    into lists corresponding to the trimmed sentences.

    Args:
        original_sentence_spans: list of lists of (start, end) int tuples that came out of the
            tokenizer. All locations with respect to the beginning of the document.
        trimmed_sentence_spans: list of lists of (start, end) int tuples, each sentence starting at
            zero, after splitting any long sentences into multiple chunks.

    Returns:
        adjusted spans: spans pointing to the original document, but regrouped into new lists
            anytime a sentence was split.
    """
    if len(original_sentence_spans) == 0:
        return [[]]
    original_sentence_index = 0
    sentence_break = 0
    adjusted_spans = []
    for trimmed_sentence in trimmed_sentence_spans:
        original_sentence = original_sentence_spans[original_sentence_index]
        if len(trimmed_sentence) < len(original_sentence):
            new_sentence_break = sentence_break + len(trimmed_sentence)
            adjusted_spans.append(original_sentence[sentence_break:new_sentence_break])
            if new_sentence_break == len(original_sentence):
                sentence_break = 0
                original_sentence_index += 1
            else:
                sentence_break = new_sentence_break
        else:
            adjusted_spans.append(original_sentence)
            original_sentence_index += 1
    return adjusted_spans