def METHOD_NAME(a, input_bias, residual, weight, bias, eps):
    assert a.is_contiguous()
    assert weight.is_contiguous()
    assert bias.is_contiguous()
    assert residual.is_contiguous()
    # allocate output and scratch-pad for residual addition
    out = torch.empty_like(a)
    ln_input = torch.empty_like(a)
    # reshape input data into 2D tensor
    a_arg = a.view(-1, a.shape[-1])
    residual = residual.view(-1, residual.shape[-1])
    M, N = a_arg.shape
    # Less than 64KB per feature: enqueue fused kernel
    MAX_FUSED_SIZE = 65536 // a.element_size()
    BLOCK_SIZE = min(MAX_FUSED_SIZE, triton.next_power_of_2(N))
    BLOCK_SIZE = max(BLOCK_SIZE, 128)
    BLOCK_SIZE = min(BLOCK_SIZE, 4096)
    BLOCK_SIZE = BLOCK_SIZE if N <= 4096 else 8192
    # heuristics for number of warps
    num_warps = min(max(BLOCK_SIZE // 256, 1), 8)
    if input_bias is None:
        layer_norm_residual_kernel[(M, )](
            out,
            a_arg,
            residual,
            ln_input,
            weight,
            bias,
            a_arg.stride(0),
            N,
            eps,
            BLOCK_SIZE=BLOCK_SIZE,
            num_warps=num_warps,
        )
    else:
        layer_norm_residual_bias_kernel[(M, )](
            out,
            a_arg,
            residual,
            input_bias,
            ln_input,
            weight,
            bias,
            a_arg.stride(0),
            N,
            eps,
            BLOCK_SIZE=BLOCK_SIZE,
            num_warps=num_warps,
        )
    return out