def format_multitask_preds(preds):
    """
    Input format: list of dicts (one per task, named with task_name), each having a
        'predictions' list containing dictionaries that represent predictions for each sample.
        Prediction score is represented by the field {task_name}_score in each of those dicts.
    Output format: a list of lists of dictionaries, where now each dictionary include scores for all the
        tasks that were included in the input.
    """
    out = []
    score_names = [f"{task['task']}_score" for task in preds[1:]]
    first_task = preds[0]
    for sentence_idx, sentence in enumerate(first_task["predictions"]):
        out_sent = []
        for token_idx, token in enumerate(sentence):
            for task, score in zip(preds[1:], score_names):
                token[score] = task["predictions"][sentence_idx][token_idx][score]
            out_sent.append(token)
        out.append(out_sent)
    return out