def get_all_graphs(model: "ModelProto", only_main_graph: bool = False) -> list[GraphProto]:
        """Get all graphs in the model.

        :param model: ONNX model.
        :param only_main_graph: whether to return only the main graph.
        :return: list of graphs in the model.
        """
        if only_main_graph:
            return [model.graph]

        all_graphs = []
        graph_queue = [model.graph]
        while graph_queue:
            graph = graph_queue.pop(0)
            all_graphs.append(graph)
            for node in graph.node:
                for attr in node.attribute:
                    if attr.type == AttributeProto.AttributeType.GRAPH:
                        assert isinstance(attr.g, GraphProto)
                        graph_queue.append(attr.g)
                    if attr.type == AttributeProto.AttributeType.GRAPHS:
                        for g in attr.graphs:
                            assert isinstance(g, GraphProto)
                            graph_queue.append(g)
        return all_graphs
Get all graphs in the model.

        :param model: ONNX model.
        :param only_main_graph: whether to return only the main graph.
        :return: list of graphs in the model.
        
olive/passes/onnx/onnx_dag.py