def _get_k_partite_clique(
        self,
        accessible_leaves: list[list[LeafNode]],
        label: int,
        target_label: int | None,
    ) -> tuple[float, list]:
        """
        Find the K partite cliques among the accessible leaf nodes.

        :param accessible_leaves: list of lists of accessible leaf nodes.
        :param label: The try label of the current sample.
        :param target_label: The target label.
        :return: The best score and a list of new cliques.
        """
        new_nodes_list = []
        best_scores_sum = 0.0

        # pylint: disable=too-many-nested-blocks
        for start_tree in range(0, len(accessible_leaves), self.max_clique):
            cliques_old: list[dict[str, Box | float]] = []
            cliques_new: list[dict[str, Box | float]] = []

            # Start searching for cliques
            for accessible_leaf in accessible_leaves[start_tree]:
                if (
                    self._classifier.nb_classes > 2
                    and target_label is not None
                    and target_label == accessible_leaf.class_label
                ):
                    new_leaf_value = -accessible_leaf.value
                else:
                    new_leaf_value = accessible_leaf.value
                cliques_old.append({"box": accessible_leaf.box, "value": new_leaf_value})

            # Loop over all trees
            for i_tree in range(
                start_tree + 1,
                min(len(accessible_leaves), start_tree + self.max_clique),
            ):
                cliques_new.clear()
                # Loop over all existing cliques
                for clique in cliques_old:
                    # Loop over leaf nodes in tree
                    for accessible_leaf in accessible_leaves[i_tree]:
                        leaf_box = accessible_leaf.box.get_intersection(clique["box"])  # type: ignore
                        if leaf_box.intervals:
                            if (
                                self._classifier.nb_classes > 2
                                and target_label is not None
                                and target_label == accessible_leaf.class_label
                            ):
                                new_leaf_value = -accessible_leaf.value
                            else:
                                new_leaf_value = accessible_leaf.value
                            cliques_new.append(
                                {
                                    "box": leaf_box,
                                    "value": new_leaf_value + clique["value"],  # type: ignore
                                }
                            )

                cliques_old = cliques_new.copy()

            new_nodes = []
            best_score = 0.0
            for i, clique in enumerate(cliques_old):
                # Create a new node without tree_id and node_id to represent clique
                new_nodes.append(
                    LeafNode(
                        tree_id=None,
                        class_label=label,
                        node_id=None,
                        box=clique["box"],  # type: ignore
                        value=clique["value"],  # type: ignore
                    )
                )

                if i == 0:
                    best_score = clique["value"]  # type: ignore
                else:
                    if label < 0.5 and self._classifier.nb_classes <= 2:
                        best_score = max(best_score, clique["value"])  # type: ignore
                    else:
                        best_score = min(best_score, clique["value"])  # type: ignore

            new_nodes_list.append(new_nodes)
            best_scores_sum += best_score

        return best_scores_sum, new_nodes_list

        Find the K partite cliques among the accessible leaf nodes.

        :param accessible_leaves: list of lists of accessible leaf nodes.
        :param label: The try label of the current sample.
        :param target_label: The target label.
        :return: The best score and a list of new cliques.
        
art/metrics/verification_decisions_trees.py