
    ёi                    \   S SK Jr  S SKrS SKrS SKJrJr  S SKJr  S SK	r	S SK	J
r
Jr  S SKJrJrJr  S SKJrJr  SS	KJrJr  SS
KJr  \(       a  S SKJr  S SKJr  S SK	Jr  S SKJrJrJrJ r   / r!\" S/S/S/S.5           S             S S jj5       r"        S!                     S"S jjr#\" SS/SS/5          S#             S$S jj5       r$   S%           S&S jjr%         S'                     S(S jjr&     S)               S*S jjr'\     S+               S,S jj5       r(\   S-           S.S jj5       r(S/S jr(     S+               S,S jjr)\RT                  " \)5      \(l+        g)0    )annotationsN)TYPE_CHECKINGAny)overload)_C_opsin_dynamic_mode)in_dygraph_modein_dynamic_or_pir_modein_pir_mode)ParamAliasDecoratorparam_two_alias   )
check_typecheck_variable_and_dtype)LayerHelper)Sequence)Literal)Tensor)DataLayout1DDataLayout2DDataLayout3DDataLayoutNDinputdimeps)xaxisepsilonr   r   c                l   [        5       (       a^  [        R                  " S/X0R                  S9n[        R
                  " U [        U5      X#SS5      nU [        R                  " Xv5      -  nGO[        5       (       ao  [        R                  " S/X0R                  S9n[        R
                  " U [        U5      X#SS5      n[        R                  " U [        R                  " Xv5      US9nGO,[        US[        [        4S5        [        US[        S5        [        U S	/ S
QS5        [        U R                  5      S:X  a  US:w  a  US:w  a  [        SU 35      eU[        U5      SUS.n[!        S0 [#        5       D6n	U	R%                  U R                  S9nU	R'                  SSU 0SU0US9  UR(                  R+                  UR                  S9n[        R                  " S/X4R                  S9n[        R                  " U [        R                  " XF5      US9nUb  [        R,                  " WU5        U$ W$ )aH  
Normalize ``x`` along dimension ``axis`` using :math:`L_p` norm. This layer computes

.. math::

    y = \frac{x}{ \max\left( \lvert \lvert x \rvert \rvert_p, epsilon\right) }

.. math::
    \lvert \lvert x \rvert \rvert_p = \left( \sum_i {\lvert x_i \rvert^p}  \right)^{1/p}

where, :math:`\sum_i{\lvert x_i \rvert^p}` is calculated along the ``axis`` dimension.

Parameters:
    x (Tensor): The input tensor could be N-D tensor, and the input data type could be float32 or float64.
        Alias: ``input``.
    p (float|int, optional): The exponent value in the norm formulation. Default: 2.
    axis (int, optional): The axis on which to apply normalization. If `axis < 0`, the dimension to normalization is `x.ndim + axis`. -1 is the last dimension.
        Alias: ``dim``.
    epsilon (float, optional): Small float added to denominator to avoid dividing by zero. Default is 1e-12.
        Alias: ``esp``.
    name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
    out (Tensor|None, optional): The output tensor. Default: None.

Returns:
    Tensor, the output has the same shape and data type with ``x``.

Examples:

    .. code-block:: python

        >>> import paddle
        >>> import paddle.nn.functional as F

        >>> paddle.disable_static()
        >>> x = paddle.arange(6, dtype="float32").reshape([2,3])
        >>> y = F.normalize(x)
        >>> print(y)
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.        , 0.44721359, 0.89442718],
         [0.42426404, 0.56568539, 0.70710671]])

        >>> y = F.normalize(x, p=1.5)
        >>> print(y)
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.        , 0.40862012, 0.81724024],
         [0.35684016, 0.47578689, 0.59473360]])

        >>> y = F.normalize(x, axis=0)
        >>> print(y)
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.        , 0.24253564, 0.37139067],
         [1.        , 0.97014254, 0.92847669]])

   )shape
fill_valuedtypeTFnamep	normalizer   r   )float16float32float64r   zAAxis must be 0 or -1 when x is a 1-D tensor, but received axis = )r   porderkeepdimr   p_normr#   XOuttypeinputsoutputsattrs)r.   )r	   paddlefullr#   r   r.   floatmaximumr   divider   intr   lenr!   
ValueErrorr   locals"create_variable_for_type_inference	append_opblock
create_varassign)
r   r&   r   r   outr%   r   retr6   helpers
             Y/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/nn/functional/norm.pyr'   r'   5   s   @ kkwwGmmAuQxeD&..**	kkwwGmmAuQxeDmmAv~~c7dC 	1cE3<54#4 s5{	
 qww<1trzSTXSYZ 
 Ah	
 2277agg7F3(UCL 	 	
 ii"""3kkyyImmAv~~c7dC
c3
J    c                   [        U R                  5      S:  d   S5       eUnUn/ SQnX;  a  [        SU 35      eUS   S:X  a  SOSnU	c
  U(       + n	S	nOU	(       + n[        5       (       a.  [        R
                  " U UUUUU(       + UUUU	U5      u  n        nU$ [        5       (       a.  [        R                  " U UUUUU(       + UUUU	U5      u  nnnnnnU$ [        U S
/ SQS5        UUU(       + US	U	US.nU /U/U/S.nU(       a  U/US'   U(       a  U/US'   [        S0 [        5       D6nSSKJn  U" U R                  5      S;  a  U R                  OSnUR                  USS9nUR                  USS9nUR                  U R                  5      nU/U/U/U/U/S.nU(       d  U(       a   UR                  U R                  SS9nU/US'   UR                  SUUUS9  UR!                  U5      $ )a  
Applies Batch Normalization as described in the paper Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift .

nn.functional.batch_norm is used for nn.BatchNorm1D, nn.BatchNorm2D, nn.BatchNorm3D. Please use above API for BatchNorm.

Parameters:
    x(Tensor): input value. It's data type should be float32, float64.
    running_mean(Tensor): running mean.
    running_var(Tensor): running variance.
    weight(Tensor, optional): The weight tensor of batch_norm. Default: None.
    bias(Tensor, optional): The bias tensor of batch_norm. Default: None.
    epsilon(float, optional): The small value added to the variance to prevent division by zero. Default: 1e-5.
    training(bool, optional): True means train mode which compute by batch data and track global mean and var during train period. False means inference mode which compute by global mean and var which calculated by train period. Default False.
    momentum(float, optional): The value used for the moving_mean and moving_var computation. Default: 0.9.
    data_format(str, optional): Specify the input data format, may be "NC", "NCL", "NCHW", "NCDHW", "NLC", "NHWC" or "NDHWC", where `N` is batch size, `C` is the number of the feature map, `D` is the depth of the feature, `H` is the height of the feature map, `W` is the width of the feature map, `L` is the length of the feature map. Default "NCHW".
    use_global_stats(bool|None, optional): Whether to use global mean and variance. If set to False, use the statistics of one mini-batch, if set to True, use the global statistics, if set to None, use global statistics in the test phase and use the statistics of one mini-batch in the training phase. Default: None.
    name(str|None, optional): Name for the BatchNorm, default is None. For more information, please refer to :ref:`api_guide_Name`..

Returns:
    None

Examples:
    .. code-block:: python

        >>> import paddle

        >>> x = paddle.arange(12, dtype="float32").reshape([2, 1, 2, 3])
        >>> print(x)
        Tensor(shape=[2, 1, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[0. , 1. , 2. ],
           [3. , 4. , 5. ]]],
         [[[6. , 7. , 8. ],
           [9. , 10., 11.]]]])
        >>> running_mean = paddle.to_tensor([0], dtype="float32")
        >>> running_variance = paddle.to_tensor([1], dtype="float32")
        >>> weight = paddle.to_tensor([2], dtype="float32")
        >>> bias = paddle.to_tensor([1], dtype="float32")

        >>> batch_norm_out = paddle.nn.functional.batch_norm(x, running_mean,
        ...                                             running_variance, weight, bias)
        >>> print(batch_norm_out)
        Tensor(shape=[2, 1, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[1.         , 2.99998999 , 4.99997997 ],
           [6.99996948 , 8.99995995 , 10.99994946]]],
         [[[12.99993896, 14.99992943, 16.99991989],
           [18.99990845, 20.99989891, 22.99988937]]]])

   zinput dim must be larger than 1)NCNCLNCHWNCDHWNLCNHWCNDHWCz\data_format must be one of 'NC', 'NCL', 'NCHW', 'NCDHW', 'NLC', 'NHWC', 'NDHWC' but receive r    CrN   rQ   Fr   )r(   uint16r)   r*   	BatchNorm)momentumr   is_testdata_layoutfuse_with_reluuse_global_statstrainable_statistics)r0   MeanVarianceScaleBias
batch_normr   convert_dtype)r(   rT   r)   Tr#   stop_gradient)YMeanOutVarianceOut	SavedMeanSavedVarianceReserveSpacer2   )r`   )r=   r!   r>   r   r   r`   r   batch_norm_r   r   r?   paddle.base.data_feederrb   r#   r@   rA   append_activation)r   running_meanrunning_varweightbiastrainingrV   r   data_formatrZ   r%   mean_outvariance_outtrue_data_formatr[   batch_norm_out_t1t2t3t4r6   r4   rG   rb   param_dtype
saved_meansaved_variancer5   reserve_spaces                                 rH   r`   r`      s   z qww<1??? HLM*22=@
 	

 (Nc1&vK'<$#33(.(9(9L )
%1aA 	,2,>,>L -
)BB  	!wC[	
 !#|&# 0$8
 !N$
 %hF7O"VF6N6VX69 QWW%-BB GG 	
 >>T ? 

  BBT C 
  BB177K !!$~'=$,-
 +"EEggT F M (5oGN#fgU 	 	
 ''77rI   c                   [        U R                  5      n[        U5      n[        U[        R
                  5      (       a  U/nOA[        U[        5      (       a  [        U5      nO [        U[         5      (       d  [        S5      e[        U5      nXx-
  n	Xx:  d'  [        R                  R                  XiS U5      (       d1  [        U5      n
[        SU
-   S-   U
SS -   S-   [        U5      -   5      e[        5       (       a  [        R                  " XX4U	5      nU$ [        U S/ SQS	5        0 nU /US
'   U(       a  U/US'   U(       a  U/US'   XIS.n[!        S0 [#        5       D6nSSKJn  U" U R(                  5      S:w  a  U R(                  OSnUR+                  USS9nUR+                  USS9nUR+                  U R(                  5      nUR-                  SUUUUS.XIS.S9  UR/                  U5      $ )a  
nn.LayerNorm is recommended.
For more information, please refer to :ref:`api_paddle_nn_LayerNorm` .
 .. note::
    Alias Support: The parameter name ``input`` can be used as an alias for ``x`` and the parameter name ``eps`` can be used as an alias for ``epsilon``.
    For example, ``layer_norm(input=tensor_x, eps=1e-5)`` is equivalent to ``layer_norm(x=tensor_x, epsilon=1e-5)``.

Parameters:
    x(Tensor): Input Tensor. It's data type should be bfloat16, float16, float32, float64.
        alias: ``input``.
    normalized_shape(int|list|tuple): Input shape from an expected input of
        size :math:`[*, normalized_shape[0], normalized_shape[1], ..., normalized_shape[-1]]`.
        If it is a single integer, this module will normalize over the last dimension
        which is expected to be of that specific size.
    weight(Tensor, optional): The weight tensor of layer_norm. Default: None.
    bias(Tensor, optional): The bias tensor of layer_norm. Default: None.
    epsilon(float, optional): The small value added to the variance to prevent
        division by zero. Default: 1e-05.
        alias: ``eps``.
    name(str, optional): Name for the LayerNorm, default is None. For more information, please refer to :ref:`api_guide_Name` .

Returns:
    None

Examples:

    .. code-block:: python

        >>> import paddle
        >>> paddle.seed(2023)
        >>> x = paddle.rand((2, 2, 2, 3))
        >>> layer_norm_out = paddle.nn.functional.layer_norm(x, x.shape[1:])
        >>> print(layer_norm_out)
        Tensor(shape=[2, 2, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[ 0.87799639, -0.32706568, -1.23529339],
           [ 1.01540327, -0.66222906, -0.72354043]],
          [[ 1.24183702,  0.45458138, -0.33506915],
           [ 0.41468468,  1.26852870, -1.98983312]]],
         [[[ 0.02837803,  1.27684665, -0.90110683],
           [-0.94709367, -0.15110941, -1.16546965]],
          [[-0.82010198,  0.11218392, -0.86506516],
           [ 1.09489357,  0.19107464,  2.14656854]]]])

@`normalized_shape` should be int, list of ints or tuple of ints.NGiven normalized_shape is  , expected input with shape [*, r    , but got input shape r   )rT   r(   r)   r*   	LayerNormr0   r^   r_   )r   begin_norm_axis
layer_normr   ra   r(   r)   Trc   re   r\   r]   r2   )r   )listr!   r=   
isinstancenumbersIntegraltupler>   r7   utilsis_same_shapestrr
   r   r   r   r   r?   rl   rb   r#   r@   rA   rm   )r   normalized_shaperp   rq   r   r%   input_shape
input_ndimnormalized_ndimr   str_normalized_shaperE   r4   r6   rG   rb   r}   rt   ru   layer_norm_outs                       rH   r   r   Q  s:   j qww-K[!J"G$4$455,-	$e	,	, 01($//N
 	
 *+O 2O#LL&&()+;
 
  ##34("#01 #12&' '	'
 +
 	
 4/J
 	!wC[	
 cs%hF7O"VF6N#H 6VX69 %QWW-:AGG	 	 <<T = 
 @@T A 
  BB177K# (
 &J 	 		
 ''77rI   c                L   [        U R                  5      n[        U5      n[        U[        R
                  5      (       a  U/nOA[        U[        5      (       a  [        U5      nO [        U[         5      (       d  [        S5      e[        U5      nXg-
  nXg:  d'  [        R                  R                  XXS U5      (       d1  [        U5      n	[        SU	-   S-   U	SS -   S-   [        U5      -   5      eUS:w  a  [        SU-   S-   5      eUc  [        S	5      e[        5       (       a  [        R                  " XU5      $ [        S0 [!        5       D6n
SSKJn  U" U R&                  5      nU
R)                  U5      nU
R)                  S5      nXS.nU
R+                  S
UXS.SU0S9  X4$ )a  
Applies Layer Normalization over the last dimension of the input tensor using CUDA implementation.
Args:
    input (Tensor): Input tensor of shape [rows, cols] or higher dimensions (flattened to 2D).
    normalized_shape(int|list|tuple): Input shape from an expected input of
        size :math:`[*, normalized_shape[0], normalized_shape[1], ..., normalized_shape[-1]]`.
        If it is a single integer, this module will normalize over the last dimension
        which is expected to be of that specific size.
    weight(Tensor, optional): The weight tensor of rms_norm. Default: None.
    eps(float, optional): The small value added to the variance to prevent division by zero. Default: 1e-05.
    name (str, optional): Name of the operator.
Returns:
    out (Tensor): Normalized tensor of same shape as input.
    invvar (Tensor): Tensor of shape [rows], the inverse standard deviation of each row.
r   Nr   r   r    r   zGiven len(normalized_shape) is z&, expected len(normalized_shape) is 1.zweight must not be None.rms_normr   ra   r)   )r   rp   )rE   invvarr   r2   )r   )r   r!   r=   r   r   r   r   r>   r7   r   r   r   r
   r   fused_rms_norm_extr   r?   rl   rb   r#   r@   rA   )r   r   rp   r   r%   r   r   r   r   r   rG   rb   r#   rE   r   r4   s                   rH   r   r     s   , u{{#K[!J"G$4$455,-	$e	,	, 01($//N
 	
 *+O 2O#LL&&()+;
 
  ##34("#01 #12&' '	'
 +
 	
 !-67
 	
 ~344((<<0vx0F5%++&E

3
3E
:C66yAF/F
.cl	   ;rI   c
                   [        5       (       a  [        R                  " XXG5      n
U
$ [        U S/ SQS5        UUUS.nU(       a  U(       a
  U /U/U/S.nOSU /0n[	        S0 [        5       D6nUR                  U R                  SS	9nUR                  U R                  SS	9nUR                  U R                  5      nU/U/U/S
.nUR                  SUUUS9  U$ )a;  
It is recommended to use :ref:`api_paddle_nn_InstanceNorm1D` , :ref:`api_paddle_nn_InstanceNorm2D` , :ref:`api_paddle_nn_InstanceNorm3D` to call this method internally.

Parameters:
    x (Tensor): Input Tensor. It's data type should be float32, float64.
    running_mean (Tensor, optional): running mean. Default None. Obsolete (that is, no longer usable).
    running_var (Tensor, optional): running variance. Default None. Obsolete (that is, no longer usable).
    weight (Tensor, optional): The weight tensor of instance_norm. Default: None.
        If its value is None, this parameter will be initialized by one.
    bias (Tensor, optional): The bias tensor of instance_norm. Default: None.
        If its value is None, this parameter will be initialized by zero.
    eps (float, optional): A value added to the denominator for numerical stability. Default is 1e-5.
    momentum (float, optional): The value used for the moving_mean and moving_var computation. Default: 0.9.
    use_input_stats (bool, optional): Default True. Obsolete (that is, no longer usable).
    data_format (str, optional): Specify the input data format, may be "NC", "NCL", "NCHW" or "NCDHW". Default "NCHW".
    name (str|None, optional): Name for the InstanceNorm, default is None. For more information, please refer to :ref:`api_guide_Name`..

Returns:
    None.

Examples:

    .. code-block:: python

        >>> import paddle
        >>> paddle.seed(2023)
        >>> x = paddle.rand((2, 2, 2, 3))
        >>> instance_norm_out = paddle.nn.functional.instance_norm(x)

        >>> print(instance_norm_out)
        Tensor(shape=[2, 2, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[ 1.25768495, -0.18054862, -1.26451230],
           [ 1.42167914, -0.58056390, -0.65373862]],
          [[ 0.95882601,  0.25075224, -0.45947552],
           [ 0.21486834,  0.98283297, -1.94780385]]],
         [[[ 0.40697321,  1.90885782, -0.71117985],
           [-0.76650119,  0.19105314, -1.02920341]],
          [[-1.06926346, -0.18710862, -1.11180890],
           [ 0.74275863, -0.11246002,  1.73788261]]]])

r   )r)   r*   r(   rT   InstanceNorm)r   rV   rs   )r0   r^   r_   r0   instance_normTrc   )re   rh   ri   r2   )r   )	r
   r   r   r   r   r?   r@   r#   rA   )r   rn   ro   rp   rq   use_input_statsrV   r   rs   r%   rE   r6   r4   rG   r~   r   instance_norm_outr5   s                     rH   r   r   !  s   j ""1d8
 7		
  &
 d3&D6BFA3ZF99>>'' ? 

  BB'' C 
 #EEaggN $$$,-
 	  	 	
 ! rI   c           
     |   [        5       (       d  [        U SSS/S5        US;  a  [        SU 35      eU R                  n[	        U5      nUS:  a  [        SU S	35      e[        U5       H$  u  pU
S
:  a  M  U	S
:  d  M  [        SU	 SU
 35      e   US   S:X  a  SOSnS
SKJn  U" S USS S5      n[        R                  " [        R                  " X 5      SS9nU(       dN  S
S
US-  US-
  S-  /nUS4nUS
   SUS   US   [        XS   US   -  -  5      /nS
S
S
S
US-  US-
  S-  /nUSS4nOMUS-  US-
  S-  S
S
/nSU4nUS
   SUS   [        XS   US   -  -  5      US   /nUS-  US-
  S-  S
S
S
S
/nSSU4nUS:X  af  [        R                  R                  R                  XS9n[        R                  R                  R                  UUSS9n[        R                   " USS9nO[        R"                  " UUS9n[        R                  R                  R                  UUSS9n[        R                  R                  R%                  UUSS9n[        R"                  " [        R                   " USS9U5      n[        R&                  " XUS9n[        R(                  " X5      n[        R*                  " XUS9nU$ )a6	  
Local Response Normalization performs a type of "lateral inhibition" by normalizing over local input regions.
For more information, please refer to `ImageNet Classification with Deep Convolutional Neural Networks <https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf>`_

The formula is as follows:

.. math::

    Output(i, x, y) = Input(i, x, y) / \left(k + \alpha \sum\limits^{\min(C-1, i + size/2)}_{j = \max(0, i - size/2)}(Input(j, x, y))^2\right)^{\beta}

In the above equation:

- :math:`size` : The number of channels to sum over.
- :math:`k` : The offset (avoid being divided by 0).
- :math:`\\alpha` : The scaling parameter.
- :math:`\\beta` : The exponent parameter.


Args:
    x (Tensor): The input 3-D/4-D/5-D tensor. The data type is float16 or float32.
    size (int): The number of channels to sum over.
    alpha (float, optional): The scaling parameter, positive. Default:1e-4
    beta (float, optional): The exponent, positive. Default:0.75
    k (float, optional): An offset, positive. Default: 1.0
    data_format (str, optional): Specify the data format of the input, and the data format of the output
        will be consistent with that of the input. An optional string from:
        If x is 3-D Tensor, the string could be `"NCL"` or `"NLC"` . When it is `"NCL"`,
        the data is stored in the order of: `[batch_size, input_channels, feature_length]`.
        If x is 4-D Tensor, the string could be  `"NCHW"`, `"NHWC"`. When it is `"NCHW"`,
        the data is stored in the order of: `[batch_size, input_channels, input_height, input_width]`.
        If x is 5-D Tensor, the string could be  `"NCDHW"`, `"NDHWC"` . When it is `"NCDHW"`,
        the data is stored in the order of: `[batch_size, input_channels, input_depth, input_height, input_width]`.
    name (str|None, optional): Name for the operation (optional, default is None). For more information,
        please refer to :ref:`api_guide_Name`.

Returns:
    A tensor storing the transformation result with the same shape and data type as input.


Examples:

    .. code-block:: pycon

        >>> import paddle

        >>> x = paddle.rand(shape=(3, 3, 112, 112), dtype="float32")
        >>> y = paddle.nn.functional.local_response_norm(x, size=5)
        >>> print(y.shape)
        paddle.Size([3, 3, 112, 112])

r   r(   r)   local_response_norm)rM   rP   rN   rQ   rO   rR   zNdata_format should be in one of [NCL, NCHW, NCDHW, NLC, NHWC, NDHWC], but got r   z4Expected 3D or higher dimensionality input, but got z dimensionsr   zCExpected every dim's size to be larger than 0, but the size of the z-th dim is r+   rS   TF)reducec                
    X-  $ N )r   ys     rH   <lambda>%local_response_norm.<locals>.<lambda>  s    AErI   r    N)r   rK   )pad)kernel_sizestride)r!   rO   )r   rs   )scalerq   r$   )r   r   r>   r!   r=   	enumerate	functoolsr   r7   	unsqueezemultiplyr<   nn
functionalr   
avg_pool2dsqueezereshape
avg_pool3dr   powr;   )r   sizealphabetakrs   r%   sizesr   iszchannel_lastr   	sum_sizesdivpad4d_shapepool2d_shapereshape_shapepad5d_shapepool3d_shaperess                        rH   r   r     s    x  sY	*,A	
 JJ"m%
 	

 GGE
e*C
QwB3%{S
 	
 5!Av!a%''(cRD:  " 'r?c14uL )59a8I


6??10q
9C!TQYa8ay!H!H!H	1Xa012
 !Q419taxAo>a|qy4!8/1a84y!H!H	1Xb	123"I
 qy4!8/1aA>1d|
axii""&&s&<ii""--\! . 
 nnSq)nnS6ii""&&[g ' 
 ii""--\! . 
 nnV^^Ca8%@
,,sa
0C
**S
C
--T
*CJrI   c                    g r   r   )r   
num_groupsr   rp   rq   rs   r%   s          rH   
group_normr     s     rI   c                    g r   r   )r   r   rp   rq   r   s        rH   r   r     s     rI   c                   ^ [        U 5      nU[        T5      -   S:  a  [        SU S[        T5       S35      eSU4S jjnST;   a  U" STR                  S5      5        ST;   a  U" S	TR                  S5      5        US
:  aY  [        U S   [        5      (       dA  / SQn[        [        US-
  [        U5      5      5       H  nU" XE   XS-      5        M     U SS n [        U 0 TD6$ )a  
nn.GroupNorm is recommended.
For more information, please refer to :ref:`api_paddle_nn_GroupNorm` .

This function has two functionalities, depending on the parameters passed:

1. ``group_norm(Tensor input, int num_groups, Tensor weight = None, Tensor bias = None, float eps = 1e-05)``:
    PyTorch compatible group_norm.

2. ``group_norm(Tensor x, int num_groups, float epsilon = 1e-05, Tensor weight = None, Tensor bias = None,
    DataLayout1D | DataLayout2D | DataLayout3D data_format = 'NCHW', str | None name = None)``:
    The original paddle.nn.functional.group_norm, see the following docs.

Parameters:
    x(Tensor): Input Tensor with shape: attr:`(batch, num_features, *)`.
        alias: ``input``.
    num_groups(int): The number of groups that divided from channels.
    epsilon(float, optional): The small value added to the variance to prevent
        division by zero. Default: 1e-05.
        alias: ``eps``.
    weight(Tensor, optional): The weight Tensor of group_norm, with shape: attr:`[num_channels]`.
        Default: None.
    bias(Tensor, optional): The bias Tensor of group_norm, with shape: attr:`[num_channels]`.
        Default: None.
    data_format(str, optional): Specify the input data format. Support "NCL", "NCHW", "NCDHW", "NLC", "NHWC" or "NDHWC". Default: "NCHW".
    name(str|None, optional): Name for the GroupNorm, default is None. For more information, please refer to :ref:`api_guide_Name`..

Returns:
    Tensor, the output has the same shape with ``x``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.seed(100)
        >>> x = paddle.arange(48, dtype="float32").reshape((2, 6, 2, 2))
        >>> group_norm_out = paddle.nn.functional.group_norm(x, num_groups=6)

        >>> print(group_norm_out)
        Tensor(shape=[2, 6, 2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]]],
         [[[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]],
          [[-1.34163547, -0.44721183],
           [ 0.44721183,  1.34163547]]]])
rK   z(Too few arguments in the function call: z, a(  . Expect one of: 
 - (Tensor input, int num_groups, Tensor weight = None, Tensor bias = None, float eps = 1e-05)
 - (Tensor x, int num_groups, float epsilon = 1e-05, Tensor weight = None, Tensor bias = None, DataLayout1D | DataLayout2D | DataLayout3D data_format = 'NCHW', str | None name = None)c                :   > U T;   a  [        SU  S35      eUTU '   g )Nz"got multiple values for argument '')	TypeError)keyvaluekwargss     rH   safe_set_param"group_norm.<locals>.safe_set_paramm  s(    &=@QGHHsrI   r   r   r   r   r   )rp   rq   r   N)r   r   r   r   )r=   r   popr   r9   rangemin_group_norm_wrapper)argsr   len_argsr   
param_keysidxs    `    rH   r   r   !  s    F 4yH#f+!6xj3v;- Pg g
 	

 &sFJJw/0y&**U"341}ZQ772
X\3z?;<C:?DqM: =BQx///rI   c           	        US;  a  [        SU-   5      eUS   S:X  a  SOSn[        5       (       a  [        R                  " U UUUUU5      $ [	        S0 [        5       D6nUR                  U R                  SS	9nUR                  U R                  SS	9n	S
U 0n
Ub  XJS'   Ub  X:S'   UR                  U R                  S9nUR                  SU
UUU	S.UUUS.S9  UR                  U5      $ )N)rM   rN   rO   rP   rQ   rR   zunsupported data layout:r    rS   rN   rQ   r   Trc   r0   r_   r^   r/   r   )r   groupsrX   r2   )r   )
r>   r
   r   r   r   r?   r@   r#   rA   rm   )r   r   r   rp   rq   rs   r%   rG   rt   ru   r4   group_norm_outs               rH   r   r     s>    JJ3kABB'Nc1&vK  
 	
 6VX6<<'' = 
 @@'' A 
 q!6N$7O  BB'' C 
 	# ( #$* 	 	
 ''77rI   )rK   r    g-q=NN)r   r   r&   r9   r   r<   r   r9   rE   Tensor | Noner%   
str | Nonereturnr   )NNF?h㈵>rN   NN)rn   r   ro   r   rp   r   rq   r   rr   boolrV   r9   r   r9   rs   r   rZ   zbool | Noner%   r   r   r   )NNr   N)r   r   r   int | Sequence[int]rp   r   rq   r   r   r9   r%   r   r   r   )Nr   N)r   r   r   r   rp   r   r   r9   r%   r   r   ztuple[Tensor, Tensor])	NNNNTr   r   rN   N)r   r   rn   r   ro   r   rp   r   rq   r   r   r   rV   r9   r   r9   rs   z%Literal['NC', 'NCL', 'NCHW', 'NCDHW']r%   r   r   r   )g-C6?g      ?g      ?rN   N)r   r   r   r<   r   r9   r   r9   r   r9   rs   *DataLayout1D | DataLayout2D | DataLayout3Dr%   r   r   r   )r   NNrN   N)r   r   r   r<   r   r9   rp   r   rq   r   rs   r   r%   r   r   r   )NNr   )r   r   r   r<   rp   r   rq   r   r   r9   r   r   )r   r   r   r   r   r   ),
__future__r   inspectr   typingr   r   typing_extensionsr   r7   r   r   paddle.base.frameworkr	   r
   r   paddle.utils.decorator_utilsr   r   base.data_feederr   r   base.layer_helperr   collections.abcr   r   r   paddle._typingr   r   r   r   __all__r'   r`   r   r   r   r   r   r   	signature__signature__r   rI   rH   <module>r      s   #   % &  * 

 E ,(   G9ug5'JK fff f 	f
 
f f f LfZ ! &$(o8o8 o8 	o8
 o8 o8 o8 o8 o8 "o8 o8 o8d #w)U!34 !{8{8){8 {8 	{8
 {8 {8 {8 5{8B !NN)N N 
	N
 N Nf #'!%  9?]!]!]! ]! 	]!
 ]! ]! ]! 
]! 7]! ]! ]!F >DGG
G G 	G
 G <G G GT 
  >D  	
  <   
 
 !  	
 
  
\0D  >D:8:8:8 :8 	:8
 :8 <:8 :8 :8z #,,-@A
 rI   