def _merge_view_ops_for(graph: List[Tensor], tensor: Tensor) -> List[Tensor]:
    """
    `tensor` should have exactly 1 src op, and that op must be a view op. We
    will look for view ops in the dst ops and merge them with the src view op
    by creating a new reshape op.
    """
    src_op = tensor._attrs["src_ops"][0]
    in_tensor = src_op._attrs["inputs"][0]
    dst_ops = tensor._attrs["dst_ops"]
    removed_ops: Set[Operator] = set()
    for op in dst_ops:
        if op._attrs["op"] not in _VIEW_OPS:
            continue
        out_tensor = op._attrs["outputs"][0]
        in_shape = in_tensor._attrs["shape"]
        out_shape = out_tensor._attrs["shape"]
        if out_shape == in_shape and not (
            _is_inout(in_tensor) and _is_inout(out_tensor)
        ):
            # If the shapes are identical, we can eliminate both view ops
            transform_utils.replace_tensor(out_tensor, in_tensor)
        else:
            # Otherwise, create a new reshape op to replace the two view ops
            out_shape = convert_shape_to_IntVarTensor(out_tensor)
            new_out_tensor = ops.reshape()(in_tensor, out_shape)
            if out_tensor._attrs["is_output"]:
                new_out_tensor._attrs["is_output"] = True
                new_out_tensor._attrs["name"] = out_tensor._attrs["name"]
            transform_utils.replace_tensor(out_tensor, new_out_tensor)
            graph.append(new_out_tensor)
        graph.remove(out_tensor)
        removed_ops.add(op)
    for op in removed_ops:
        transform_utils.remove_view_op_from_sorted_graph(op)
    return graph
`tensor` should have exactly 1 src op, and that op must be a view op. We
will look for view ops in the dst ops and merge them with the src view op
by creating a new reshape op.
python/aitemplate/compiler/transform/transform_merge_view_ops.py