human
Complete the below
def alpha_merge(cls, alpha_in, beta_in):

    ''''Decorator to merge multiplication by a scalar on the output.
    This will find a pattern of `scal * <yourop>(some, params, alpha,
    beta)` and update it so that the scalar multiplication happens as
    part of your op.
    The op needs to accept an alpha and a beta scalar which act this way::
    out = Op() * alpha + out_like * beta
    Where out_like is a buffer that has the same size as the output
    and gets added to the "real" output of the operation.  An example
    of an operation that respects this pattern is GEMM from blas.
    The decorated function must have this signature::
    maker(node, *inputs)
    The `node` argument you recieve is the original apply node that
    contains your op.  You should use it to grab relevant properties
    for your op so that the new version performs the same computation.
    The `*inputs` parameters contains the new inputs for your op.  You
    MUST use those inputs instead of the ones on `node`.  Note that
    this function can be as simple as::
    def maker(node, *inputs):
    return node.op(*inputs)
    Parameters
    cls : op class
    The class of the op you want to merge
    alpha_in : int
    The input index for the alpha scalar for your op (in node.inputs).
    beta_in : int
    The input index for the beta scalar for your op (in node.inputs).
    Returns
    local optimizer
    an unregistered local optimizer that has the same name as the
    decorated function.
    Notes
    This was factored out since the code to deal with intervening
    transfers and correctness in the presence of different values of
    alpha and beta scaling factors is not trivial.'
    '''
assistant
#Here is Python program to find a pattern of `scal * <yourop>(some, params, alpha,
.
    def wrapper(maker):
        @local_optimizer([GpuElemwise])
        @wraps(maker)
        def opt(node):
            if (isinstance(node.op, GpuElemwise) and (node.op.scalar_op == scal.mul) and (node.nin == 2)):
                targ = find_node(node.inputs[0], cls)
                if (targ is None):
                    targ = find_node(node.inputs[1], cls)
                    if (targ is None):
                        return
                    lr = grab_cpu_scalar(node.inputs[0], nd=targ.outputs[0].ndim)
                else:
                    lr = grab_cpu_scalar(node.inputs[1], nd=targ.outputs[0].ndim)
                if ((lr is None) or (lr.dtype != targ.outputs[0].dtype)):
                    return None
                inputs = list(targ.inputs)
                try:
                    c = get_scalar_constant_value(lr)
                    if (c == 0):
                        inputs[alpha_in] = lr
                        inputs[beta_in] = lr
                    elif (c == 1):
                        inputs[alpha_in] = targ.inputs[alpha_in]
                        inputs[beta_in] = targ.inputs[beta_in]
                    else:
                        inputs[alpha_in] = (lr * targ.inputs[alpha_in])
                        inputs[beta_in] = (lr * targ.inputs[beta_in])
                except NotScalarConstantError:
                    inputs[alpha_in] = (lr * targ.inputs[alpha_in])
                    inputs[beta_in] = (lr * targ.inputs[beta_in])
                return maker(targ, *inputs)
        return opt
    return wrapper