def get_ancestors_by_prediction(
    label_schema: LabelSchemaEntity, prediction: ScoredLabel
) -> List[ScoredLabel]:
    """
    Get all the ancestors for a given label node
    """
    ancestor_labels = label_schema.get_ancestors(prediction.get_label())
    return [ScoredLabel(al, prediction.probability) for al in ancestor_labels]
    def test_scored_label(self):
        """
        <b>Description:</b>
        Check the ScoredLabel can correctly return the value

        <b>Input data:</b>
        LabelEntity

        <b>Expected results:</b>
        Test passes if the results match
        """
        car = LabelEntity(id=ID(123456789),
                          name="car",
                          domain=Domain.DETECTION,
                          is_empty=True)
        person = LabelEntity(id=ID(987654321),
                             name="person",
                             domain=Domain.DETECTION,
                             is_empty=True)
        car_label = ScoredLabel(car)
        person_label = ScoredLabel(person)

        for attr in [
                "id", "name", "color", "hotkey", "creation_date", "is_empty"
        ]:
            assert getattr(car_label, attr) == getattr(car, attr)

        assert car_label.get_label() == car
        assert car_label == ScoredLabel(car)
        assert car_label != car
        assert car_label != person_label
        assert hash(car_label) == hash(str(car_label))

        probability = 0.0
        assert car_label.probability == probability
        delta_probability = 0.4
        probability += delta_probability
        car_label.probability += delta_probability
        assert car_label.probability == probability

        car.color = Color(red=16, green=15, blue=56, alpha=255)
        assert (
            "ScoredLabel(123456789, name=car, probability=0.4, domain=DETECTION, color="
            in repr(car_label))
        assert "Color(red=16, green=15, blue=56, alpha=255), hotkey=ctrl+0)" in repr(
            car_label)