def preprocess(
        sources: Sequence[Sequence[str]],
        scores: Sequence[Sequence[float]],
        instructions: Sequence[str],
        outputs: Sequence[Sequence[str]],
        ids: Sequence[int],
        tokenizer: transformers.PreTrainedTokenizer,
) -> List[Dict]:
    """sort the sources by scores and tokenize them."""
    num_generations = len(sources[0])
    assert len(set(len(s) for s in sources)) == 1, "All sources should have the same number of generations."
    # Sort the sources by scores, keep only the source string
    ss_sorted = [sorted(zip(source, score), key=lambda x: x[1], reverse=True) for source, score in zip(sources, scores)]
    sources_sorted = [[s[0] for s in ss] for ss in ss_sorted]
    scores_sorted = [[s[1] for s in ss] for ss in ss_sorted]

    list_data_dict = [_tokenize_fn(so, sc, ins, tokenizer)
                      for so, sc, ins in zip(sources_sorted, scores_sorted, instructions)]

    return list_data_dict
sort the sources by scores and tokenize them.
tuna/src/train_tuna.py