def _find_fused_node_with_cur_add(node, ops):
    r"""
    Find a node before the cur node which can be fused with cur add node, which used to check
    whether has a node can be fused with add.
    """
    if len(node.pre_nodes) == 0:
        return None
    if len(node.pre_nodes) > 0:
        if (
            node.pre_nodes[0].type in ops
            and len(node.pre_nodes[0].post_nodes) == 1
            and node.pre_nodes[0].qconfig is not None
        ):
            return node.pre_nodes[0]
        elif (
            node.pre_nodes[0].type == str(nn.Identity)
            and len(node.pre_nodes[0].post_nodes) == 1
            and len(node.pre_nodes[0].pre_nodes) > 0
        ):
            fused_node = _find_fused_node_with_cur_add(node.pre_nodes[0], ops)
            if fused_node is not None:
                return node.pre_nodes[0]
            else:
                return None

        if len(node.pre_nodes) == 2:
            if (
                node.pre_nodes[1].type in ops
                and len(node.pre_nodes[1].post_nodes) == 1
                and node.pre_nodes[1].qconfig is not None
            ):
                return node.pre_nodes[1]
            elif (
                node.pre_nodes[1].type == str(nn.Identity)
                and len(node.pre_nodes[1].post_nodes) == 1
                and len(node.pre_nodes[1].pre_nodes) > 0
            ):
                fused_node = _find_fused_node_with_cur_add(node.pre_nodes[1], ops)
                if fused_node is not None:
                    return node.pre_nodes[1]
                else:
                    return None
        return None

    Find a node before the cur node which can be fused with cur add node, which used to check
    whether has a node can be fused with add.
    
intel_extension_for_pytorch/quantization/_recipe.py