def _collect_info(
    output_op_map: Dict[str, Set[Operator]],
    all_ops: Set[Operator],
    sorted_graph: List[Tensor],
) -> List[FusedElementwiseInfo]:
    """
    Collects information for each fused_elementwise op:
        1. Provide op_list in topological order so fuse_elementwise backend can emit operations in order.
        2. Provide inputs outputs info of each subgraph. This need to happen before fuse ops are created,
        i.e. graph get changed.
    Returns list of fused_op_info, which contains:
        partitioned op list in topological order, all inputs/outputs of elementwise ops and
        their external input/output, serving as input/output of fused_elementwise op.
    """
    info_list = []
    for op_set in output_op_map.values():
        # Toposort the op_set into op_list
        # because fuse_elementwise stores elementwise ops in topological order
        topo_set = set()
        op_list = []
        for tensor in sorted_graph:
            topo_set.add(tensor)
            to_remove = set()
            for op in op_set:
                if all([arg in topo_set for arg in op._attrs["inputs"]]):
                    op_list.append(op)
                    to_remove.add(op)
            op_set = op_set - to_remove
        assert (
            not op_set
        ), "Unable to find topological order of op list for fused_elementwise!"
        # Get all inputs/outputs of elementwise ops and their external input/output,
        # which will serve as input/output of fused_elementwise op.
        inputs_outputs = _get_inputs_outputs(op_list, all_ops)
        fused_op_info = FusedElementwiseInfo(op_list, *inputs_outputs)
        info_list.append(fused_op_info)
    return info_list
Collects information for each fused_elementwise op:
1. Provide op_list in topological order so fuse_elementwise backend can emit operations in order.
2. Provide inputs outputs info of each subgraph. This need to happen before fuse ops are created,
i.e. graph get changed.
Returns list of fused_op_info, which contains:
partitioned op list in topological order, all inputs/outputs of elementwise ops and
their external input/output, serving as input/output of fused_elementwise op.
python/aitemplate/compiler/transform/fuse_ops.py