def add_layer_norm(
    residual: torch.Tensor,
    x: torch.Tensor,
    weight: torch.Tensor,
    bias: torch.Tensor,
    eps: float,
    add_back: bool = False,
):
    r"""
    Add residual on input x and apply layernorm on the result.

    Args:
        residual (torch.Tensor): residual to add with x. If residual is None,
            it means only apply layernorm on x.
        x (torch.Tensor) : the input tensor to add residual and apply layernorm.
        weight (torch.Tensor): the weight to apply layernorm.
        bias (torch.Tensor): the bias to apply layernorm.
        eps (float) : the variance_epsilon to apply layernorm.
        add_back (bool) : whether to store the result of (x + residual) back
            to the residual buffer (if residual is not None). Default is False.

    """
    f = _get_function_from_device(x.device.type, add_layer_norm)
    return f(residual, x, weight, bias, eps, add_back)

    Add residual on input x and apply layernorm on the result.

    Args:
        residual (torch.Tensor): residual to add with x. If residual is None,
            it means only apply layernorm on x.
        x (torch.Tensor) : the input tensor to add residual and apply layernorm.
        weight (torch.Tensor): the weight to apply layernorm.
        bias (torch.Tensor): the bias to apply layernorm.
        eps (float) : the variance_epsilon to apply layernorm.
        add_back (bool) : whether to store the result of (x + residual) back
            to the residual buffer (if residual is not None). Default is False.

    
intel_extension_for_pytorch/llm/functional/fusions.py