    def set_edges(nodes: Dict[str, NodeRepr], top_sort: list):
        """Set in_edges and out_edges for the node, and return the nodes and edge.

        Args:
            nodes (`Dict[str, NodeRepr]`): All the nodes repr from DAG.
            top_sort (`list`): Topological list.

        Returns:
            Dict[str, NodeRepr]: The nodes update in_edges and out_edges.
            Dict[str, Dict]: The edges for the DAG.
        """
        out_id = 0
        edges = {out_id: DAGRepr.get_edge_from_schema(nodes[InputConst.name].outputs, nodes[InputConst.name].inputs, nodes[InputConst.name].outputs,
                                                      nodes[InputConst.name].iter_info.type, None)}
        nodes[InputConst.name].in_edges = [out_id]

        for name in top_sort[:-1]:
            ahead_schema = set(nodes[name].outputs)
            for i in nodes[name].in_edges:
                ahead_schema = ahead_schema | edges[i]['schema'].keys()
            for next_name in nodes[name].next_nodes:
                out_id += 1
                out_schema = DAGRepr.dfs_used_schema(nodes, next_name, ahead_schema)
                edges[out_id] = DAGRepr.get_edge_from_schema(tuple(out_schema), nodes[name].inputs, nodes[name].outputs,
                                                             nodes[name].iter_info.type, [edges[e]['schema'] for e in nodes[name].in_edges])

                if nodes[next_name].in_edges is None:
                    nodes[next_name].in_edges = [out_id]
                else:
                    nodes[next_name].in_edges.append(out_id)

                if nodes[name].out_edges is None:
                    nodes[name].out_edges = [out_id]
                else:
                    nodes[name].out_edges.append(out_id)

        out_id += 1
        final_edge = nodes[OutputConst.name].in_edges[0]
        final_schema = edges[final_edge]['schema']
        edges[out_id] = {'schema': final_schema, 'data': [(s, final_schema[s].type) for s in nodes[OutputConst.name].inputs]}

        nodes[OutputConst.name].out_edges = [out_id]
        return nodes, edges
Set in_edges and out_edges for the node, and return the nodes and edge.

Args:
nodes (`Dict[str, NodeRepr]`): All the nodes repr from DAG.
top_sort (`list`): Topological list.

Returns:
Dict[str, NodeRepr]: The nodes update in_edges and out_edges.
Dict[str, Dict]: The edges for the DAG.
towhee/runtime/dag_repr.py