def layer_normalization(
    x, gamma=None, beta=None, axis=-1, epsilon=None, rms_scaling=False
):
    """Layer normalization layer (Ba et al., 2016).

    Normalize the activations of the previous layer for each given example in a
    batch independently, rather than across a batch like Batch Normalization.
    i.e. applies a transformation that maintains the mean activation within each
    example close to 0 and the activation standard deviation close to 1.
    Args:
        x: Input tensor.
        axis: The axis or axes along which to perform normalization.
            Default to -1.
        gamma: Optional scaling factor for the normalization.
        beta: Optional add offset for the normalized tensor.
        rms_scaling:This is an approximate and faster
            approach that avoids ever computing the mean of the input. Note that
            this *isn't* equivalent to the computation that rms_normalization
        epsilon: A lower bound value for the norm.
            Defaults to `backend.epsilon()`.

    Returns:
        The normalized array.
    >>> x = ops.arange(5,dtype = "float32")
    >>> x_norm = ops.layer_normalization(x)
    >>> print(x_norm)
    array([-1.4142135 , -0.70710677,  0.,  0.7071067 ,  1.4142135 ])
    """
    if any_symbolic_tensors((x,)):
        return LayerNorm(
            gamma=gamma,
            beta=beta,
            axis=axis,
            epsilon=epsilon,
            rms_scaling=rms_scaling,
        ).symbolic_call(x)
    return _layer_normalization(
        x,
        gamma=gamma,
        beta=beta,
        axis=axis,
        epsilon=epsilon,
        rms_scaling=rms_scaling,
    )
Layer normalization layer (Ba et al., 2016).

    Normalize the activations of the previous layer for each given example in a
    batch independently, rather than across a batch like Batch Normalization.
    i.e. applies a transformation that maintains the mean activation within each
    example close to 0 and the activation standard deviation close to 1.
    Args:
        x: Input tensor.
        axis: The axis or axes along which to perform normalization.
            Default to -1.
        gamma: Optional scaling factor for the normalization.
        beta: Optional add offset for the normalized tensor.
        rms_scaling:This is an approximate and faster
            approach that avoids ever computing the mean of the input. Note that
            this *isn't* equivalent to the computation that rms_normalization
        epsilon: A lower bound value for the norm.
            Defaults to `backend.epsilon()`.

    Returns:
        The normalized array.
    >>> x = ops.arange(5,dtype = "float32")
    >>> x_norm = ops.layer_normalization(x)
    >>> print(x_norm)
    array([-1.4142135 , -0.70710677,  0.,  0.7071067 ,  1.4142135 ])
    
keras/src/ops/nn.py