def get_sorted_ops(tensors) -> List[Any]:
    """
    Produces the exact execution sequence of operators.
    This matches backend/codegen.py, ModelContainerGenerator.append_all_tensors()
    """

    from aitemplate.compiler.base import Tensor

    visited = set()
    sorted_ops = []
    if isinstance(tensors, Tensor):
        tensors = [tensors]
    for tensor in tensors:
        for src_op in tensor.src_ops():
            if src_op in visited:
                continue
            visited.add(src_op)
            sorted_ops.append(src_op)
    return sorted_ops
Produces the exact execution sequence of operators.
This matches backend/codegen.py, ModelContainerGenerator.append_all_tensors()
python/aitemplate/utils/graph_utils.py