def extract_edus_tokens(edu_start_indices, tokens_doc):
    """
    Extract tokens corresponding given to the given EDU indices.

    Parameters
    ----------
    edu_start_indices : list
        List of list of indices, one list for each EDU.
    tokens_doc : list
        List of list of tokens in the given document, one list per sentence.
        The tokens can be either word tokens or part-of-speech tags or any
        other tokens that have a one-to-one correspondence with the word
        tokens.

    Returns
    -------
    tokens_list : list
        List of list of tokens corresponding to each EDU.

    Raises
    ------
    ValueError
        If an EDU crosses sentence boundaries.
    """
    res = []

    # check for blank input.
    if not edu_start_indices:
        return res

    # add a dummy index pair representing the end of the document
    tmp_indices = edu_start_indices + [[edu_start_indices[-1][0] + 1,
                                        0,
                                        edu_start_indices[-1][2] + 1]]

    for ((prev_sent_index, prev_tok_index, prev_edu_index),
         (sent_index, tok_index, _)) in zip(tmp_indices,
                                            tmp_indices[1:]):
        if sent_index == prev_sent_index and tok_index > prev_tok_index:
            res.append(tokens_doc[prev_sent_index][prev_tok_index:tok_index])
        elif sent_index > prev_sent_index and tok_index == 0:
            res.append(tokens_doc[prev_sent_index][prev_tok_index:])
        else:
            raise ValueError((f"An EDU ({prev_edu_index}) crosses sentences: "
                              f"(sent {prev_sent_index}, tok {prev_tok_index}) "
                              f"=> (sent {sent_index}, tok {tok_index})"))
    return res