    def check_nodes(nodes: Dict[str, NodeRepr], top_sort: list):
        """Check nodes if start with _input and ends with _output, and the schema has declared before using.

        Args:
            nodes (`Dict[str, NodeRepr]`): All the nodes from DAG.
            top_sort (`list`): Topological list.
        """
        if len(top_sort) != len(nodes):
            raise ValueError('The DAG is not valid, it has a circle.')
        if top_sort[0] != InputConst.name:
            raise ValueError('The DAG is not valid, it does not started with `_input`.')
        if top_sort[-1] != OutputConst.name:
            raise ValueError('The DAG is not valid, it does not ended with `_output`.')

        all_inputs = DAGRepr.get_all_inputs(nodes, top_sort)
        for name in top_sort[1:]:
            check_set(nodes[name].inputs, set(all_inputs[name]))
            check_node_iter(nodes[name].iter_info.type, nodes[name].iter_info.param,
                            nodes[name].inputs, nodes[name].outputs, set(all_inputs[name]))
Check nodes if start with _input and ends with _output, and the schema has declared before using.

Args:
nodes (`Dict[str, NodeRepr]`): All the nodes from DAG.
top_sort (`list`): Topological list.
towhee/runtime/dag_repr.py