def pattern_to_detect(conv_transpose, transpose, sub):
    """
    Wrapper to create 8 patterns to detect for conciseness.
    """

    @mb.program(input_specs=[mb.TensorSpec(shape=arbitrary_input)])
    def conv_bias_pattern(x):
        if not conv_transpose:
            conv = mb.conv(x=x, weight=arbitrary_weight, pad_type="valid", name="conv")
        else:
            conv = mb.conv_transpose(x=x, weight=arbitrary_weight, pad_type="valid", name="conv")

        if transpose:
            transpose_layer = mb.transpose(x=conv, perm=arbitrary_perm, name="transpose")

        if sub:
            add_or_sub = mb.sub(x=transpose_layer if transpose else conv, y=arbitrary_scalar, name="add_or_sub")
        else:
            add_or_sub = mb.add(x=transpose_layer if transpose else conv, y=arbitrary_scalar, name="add_or_sub")
        return add_or_sub

    return conv_bias_pattern

    Wrapper to create 8 patterns to detect for conciseness.
    
coremltools/converters/mil/experimental/passes/generic_conv_bias_fusion.py