def _fused_elementwise_ops_are_equal(op1: Operator, op2: Operator) -> bool:
    """We consider two fused elementwise to be duplicates when:
    2. Their elementwise operations are the same.
    1. And their inputs accessors are the same.

    NOTE: We assume the inputs are in the same order as the sub-elementwise
    operations. Otherwise, this is a problem because some elementwise operations
    are non-commutative.
    """
    op1_elementwise_ops = op1._attrs["elementwise_ops"]
    op2_elementwise_ops = op2._attrs["elementwise_ops"]
    op1_inputs, op2_inputs = op1._attrs["inputs"], op2._attrs["inputs"]
    op1_input_accessors = op1._attrs["input_accessors"]
    op2_input_accessors = op2._attrs["input_accessors"]
    if (
        len(op1_elementwise_ops) != len(op2_elementwise_ops)
        or len(op1_inputs) != len(op2_inputs)
        or len(op1_input_accessors) != len(op2_input_accessors)
    ):
        return False

    are_elementwise_equal = all(
        a._attrs["func"] == b._attrs["func"]
        for a, b in zip(op1_elementwise_ops, op2_elementwise_ops)
    )
    are_input_accessors_equal = all(
        input1 == input2 and input_accessor1 == input_accessor2
        for input1, input2, input_accessor1, input_accessor2 in zip(
            op1_inputs, op2_inputs, op1_input_accessors, op2_input_accessors
        )
    )
    return are_elementwise_equal and are_input_accessors_equal
We consider two fused elementwise to be duplicates when:
2. Their elementwise operations are the same.
1. And their inputs accessors are the same.

NOTE: We assume the inputs are in the same order as the sub-elementwise
operations. Otherwise, this is a problem because some elementwise operations
are non-commutative.
python/aitemplate/compiler/transform/fuse_duplicate_fused_elementwise.py