def _has_cycle(grouped_op: Operator, group: List[Operator]):
    """
    Assuming that grouped_op is in the group, determine if grouped_op
    can reach any other op in the group. Return True if it can.
    """
    assert (
        grouped_op in group
    ), f'grouped_op {grouped_op._attrs["name"]} is not from the group'
    for op in group:
        if op is grouped_op:
            continue
        if transform_utils.is_ancestor(op, grouped_op):
            return True
    return False

    Assuming that grouped_op is in the group, determine if grouped_op
    can reach any other op in the group. Return True if it can.
    
python/aitemplate/compiler/transform/fuse_group_ops.py