def _compute_negative_examples(
        label, 
        all_items, 
        pos_items, 
        item_to_labels, 
        label_graph,
        assert_ambig_neg
    ):
    """
    Compute the set of negative examples for a given label.
    This set consists of all items that are not labelled
    with a descendant of the label, but are also not labelled
    with an ancestor of the label (can include siblings).
    """
    anc_labels = label_graph.ancestor_nodes(label)
    candidate_items = set(all_items) - set(pos_items)

    if assert_ambig_neg:
        neg_items = list(candidate_items)
    else:
        # Remove items from the negatives that are labelled 
        # most specifically as an ancestor of the current label
        final_items = set()
        for item in candidate_items:
            ms_item_labels = label_graph.most_specific_nodes(
                item_to_labels[item]
            )
            ms_item_labels = set(ms_item_labels)
            if len(ms_item_labels & anc_labels) == 0:
                final_items.add(item)
        neg_items = list(final_items)
    return neg_items