
    ёi6                      S SK Jr  S SKJr  S SKrS SKJrJrJrJrJ	r	  S SK
JrJr  S SKJrJrJr  S SKJr  S SKJr  S S	KJr  S
SKJrJr  S
SKJr  S
SKJr  S
SKJr  S
SK J!r!  S
SK"J#r#J$r$  S
SK%J&r&J'r'J(r(J)r)  \(       a(  S SK*J+r+  S SKJ,r,  S SK-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  SSK7J8r8  / r9S r:S r;S r<S r=           S$                         S%S jjr>\" SS/05             S&                   S'S jj5       r?\" SS/05             S(                   S)S jj5       r@         S*                       S+S  jjrA         S,                       S-S! jjrB\" SS/05             S.                   S/S" jj5       rC         S0                       S1S# jjrDg)2    )annotations)TYPE_CHECKINGN)_C_ops_legacy_C_ops	get_flagsin_dynamic_modepir)_global_flagsin_dynamic_or_pir_mode)get_all_custom_device_typeis_compiled_with_cudais_compiled_with_rocm)reshape)_add_with_axis)ParamAliasDecorator   )check_dtypecheck_variable_and_dtype)LayerHelper)Variable)get_cudnn_version)no_grad)squeeze	unsqueeze)_contain_var_convert_to_tensor_list_is_symmetric_paddingconvert_to_list)Sequence)Tensor)	DataLayout1DDataLayout2DDataLayout3DDataLayoutNDSize1Size2Size3Size4Size6   )_PaddingSizeModec                .    [        U [        [        45      $ )N)
isinstancelisttuple)inputs    Y/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/nn/functional/conv.py_is_list_or_tupler2   B   s    edE]++    c                    U(       a-  [        U S   5      SS/:H  =(       a    [        U S   5      SS/:H  $ [        U S   5      SS/:H  =(       a    [        U S   5      SS/:H  $ )Nr   r*   )r.   )paddingchannel_lasts     r1   "_zero_padding_in_batch_and_channelr8   F   sc    GAJAq6)Id72;.?Aq6.IIGAJAq6)Hd71:.>1a&.HHr3   c                l    U(       a  U SS OU SS  nU VVs/ s H  o3  H  oDPM     M     nnnU$ s  snnf )Nr*   r5       )r6   r7   padding_	pad_a_dimelems        r1   %_exclude_padding_in_batch_and_channelr?   M   s>     ,wq}'!"+H&.Eh949hHEO Fs   0c                >   [        U [        5      (       a?  U R                  5       n U S;  a  [        SU  S35      eU S:X  a
  SnS/U-  n GO,SnS/U-  n GO"[	        U 5      (       Ga  [        U 5      SU-   :X  aX  [	        U S   5      (       aE  [        X5      (       d  [        SU  S	35      eS
n[        X5      n [        X5      (       a  U SS S2   n O[        U 5      SU-  :X  aC  [        U S   [        5      (       a+  S
n[        U SU-  S5      n [        X5      (       a  U SS S2   n OR[        U 5      U:X  a'  [        U S   [        5      (       a  S
n[        XS5      n O[        SU  35      eS
n[        XS5      n [        S U  5       5      (       d  [        SU  35      eX4$ )N)SAMEVALIDzUnknown padding: 'z$'. It can only be 'SAME' or 'VALID'.rB   r   rA   r:   zNon-zero padding(z6) in the batch or channel dimensions is not supported.EXPLICITr6   zIn valid padding: c              3  *   #    U  H	  oS :  v   M     g7f)r   Nr;   ).0ps     r1   	<genexpr>%_update_padding_nd.<locals>.<genexpr>   s     'w!Avws   zNInvalid padding, all value should be larger than or equal to 0, but received: )r-   strupper
ValueErrorr2   lenr8   r?   r   intr   all)r6   r7   num_dimspadding_algorithms       r1   _update_padding_ndrQ   S   s   '3--/++$WI-QR  g 'cHnG &cHnG	7	#	# w<1x<',=gaj,I,I5gLL 'y 1( (  !+;G %W77!!$Q$-\Q\)jS.I.I *%gq8|YGG$W77!!$Q$-\X%*WQZ*E*E *%gCG1';<< '!'Y?'w'''\]d\ef
 	
 %%r3   xc                   [        5       (       a  U
S:X  a  [        R                  " U UUUUUUU5      nUb  S/[        U R                  5      -  nSX'   UR                  U5      n[        5       S   (       aI  S[        5       ;   a;  [        5          [        R                  " US5      nUR                  U5        S S S 5        [        R                  " X5      $ U$ [        5       (       al  U
S:X  af  [        R                  " U UUUUUUU5      nUbD  S/[        U R                  5      -  nSX'   UR                  U5      n[        R                  " X5      $ U$ [        5       (       al  U
S:X  af  [        R                  " U UUUUUUU5      nUbD  S/[        U R                  5      -  nSX'   UR                  U5      n[        R                  " X5      $ U$ [        5       (       a=  S	US
USUSUSUSSSUSU4n[        [         U
5      " X/UQ76 nUb  [#        XU	S9nU$ Un U$ U /U/S.nUUUUUSUUS.n[%        U S/ SQU
5        ['        U
40 [)        5       D6nUR+                  SS9nUR-                  U5      nSU/0nUR/                  U
UUUS9  Ub  UR-                  U5      n[1        UR                  5      n[1        UR                  5      nU	S:X  d  [        U5      [        U5      :X  a  UR/                  SU/U/S.SU/0SS0S9  U$ [        U5      [        U5      :  d   S5       e[        U5      [        U5      -
  U	-
  n[        US/U	-  U-   S/U-  -   5      nUR/                  SU/U/S.SU/0SS0S9   U$ UnU$ ! , (       d  f       GN= f)Nconv2dr*   r5   FLAGS_npu_storage_formatnpur   depthwise_conv2dconv3dstridespaddings	dilationsgroups	use_cudnnfuse_relu_before_depthwise_convFrP   data_formataxisInputFilterrY   rZ   r[   r\   r]   r^   rP   r_   rR   float16uint16float32float64input_param_nameOutputtypeinputsoutputsattrselementwise_addXYOutra   ;The length of pre_bias must greater than the length of bias)r   r   rT   rL   shaper   r
   r   r   npu_identity_share_underline_tensor_toaddrW   rX   r   getattrr   r   r   r   localsinput_dtype"create_variable_for_type_inference	append_opr.   )rR   weightbiasstrider6   rP   dilationr\   r_   channel_dimop_typer]   namepre_bias	new_shapebias_storagerr   outrp   helperdtyperq   x_shapey_shapes                           r1   _conv_ndr      s     Gx$7==	
 c!''l*I%'I"<<	*D  :;799Y#)#6#6a$L !;;DA	 
 ::h--OG/A$A**	
 c!''l*I%'I"<<	*D::h--OGx$7==	
 c!''l*I%'I"<<	*D::h--O-!
$ ='21EuE kBCj Jg Cf Jc 36(3!"/4!2&	
 	!s?	
 W11""C"8<<UChZ( 	 	
 ;;EBC8>>*G4::&Gb CLCL$@  *"*4&9"SEN!2,	 ! . J! 7|c'l2 Q2 g,W5C1#+g5gE   *"*4&9"SEN!2,	 !  J CJs Ys   )M66
Nr0   c	                    [        5       n	U	b  Sn
OSn
US;  a  [        SU S35      eUS:H  nU(       a  SOSnU(       a  S	OS
n[        U R                  5      S:w  a  [        SU R                   35      eU R                  U   nUR                  S   nUS:X  a  [        S5      eX-  S:w  a9  [	        5       (       d  US:w  a$  US:w  a  [        SU SU R                   SU 35      eX-  S:w  a9  [	        5       (       d  US:w  a$  US:w  a  [        SU SUR                   SU 35      e[        XKS5      u  nn[        U5      S:X  a  SS/UQnO#[        U5      S:X  a  S/UQnO[        SU 35      eS/[        USS5      QnS/[        USS5      QnSSKJn  Sn[        R                  R                  5       S:X  ay  UR                  [        R                  :X  a  SnUR                  U R                  5      nUb;  UR                  [        R                  :X  a  SnUR                  U R                  5      nU" U5      n[        US/S9nSn[!        5       (       a  X:X  a  US:w  a  X-  S:X  a  SnSn
U(       a  SOSn[        U U/S9n [#        5       (       aS  US:X  a  [$        R&                  " U UUUUUUU5      nO![$        R(                  " U UUUUUUUSSSS5      nUb
  [+        UX,S9nOzU /U/S.nUUUUU
SUUS .n[-        U S!/ S"QS5        [/        U40 [1        5       D6nUR3                  S#S$9nUR5                  U5      nS%U/0nUR7                  UUUUS&9  Ub
  [+        UX,S9n[9        UU/S9nU(       a  UR                  [        R                  5      nU$ )'a  
The convolution1D layer calculates the output based on the input, filter
and strides, paddings, dilations, groups parameters. Input and
Output are in NCL format, where N is batch size, C is the number of
channels, L is the length of the feature.
Filter is in MCK format, where M is the number of output image channels,
C is the number of input image channels, K is the size of the kernel.
If the groups is greater than 1, C will equal the number of input image
channels divided by the groups. If bias attribution and activation type
are provided, bias is added to the output of the convolution, and the
corresponding activation function is applied to the final result.

For each input :math:`X`, the equation is:

.. math::

    Out = \sigma (W \ast X + b)

Where:

* :math:`X`: Input value, a tensor with NCL format.
* :math:`W`: Kernel value, a tensor with MCK format.
* :math:`\\ast`: Convolution operation.
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
* :math:`\\sigma`: Activation function.
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

Example:

    - Input:

      Input shape: :math:`(N, C_{in}, L_{in})`

      Filter shape: :math:`(C_{out}, C_{in}, L_f)`

    - Output:

      Output shape: :math:`(N, C_{out}, L_{out})`

    Where

    .. math::

        L_{out} = \frac{(L_{in} + 2 * padding - (dilation * (L_f - 1) + 1))}{stride} + 1

.. note::
    Alias Support: The parameter name ``input`` can be used as an alias for ``x``.

Args:
    x (Tensor): The input is 3-D Tensor with shape [N, C, L], the data type
        of input is float16 or float32 or float64.
        Alias: ``input``.
    weight (Tensor): The convolution kernel with shape [M, C/g, K], where M is
        the number of output channels, g is the number of groups, K is the kernel's size.
    bias (Tensor, optional): The bias with shape [M,]. Default: None.
    stride (int|list|tuple, optional): The stride size. If stride is a list/tuple, it must
        contain one integers, (stride_size). Default: 1.
    padding (int|str|tuple|list, optional): The padding size.
        Padding could be in one of the following forms.

        1. a string in ['valid', 'same'].
        2. an int, which means the feature map is zero paded by size of `padding` on both sides.
        3. a list[int] or tuple[int] whose length is 1, which means the feature map is zero paded by size of `padding[0]` on both sides.
        4. a list[int] or tuple[int] whose length is 2. It has the form  [pad_before, pad_after].
        5. a list or tuple of pairs of ints. It has the form [[pad_before, pad_after], [pad_before, pad_after], ...]. Note that, the batch dimension and channel dimension are also included. Each pair of integers correspond to the amount of padding for a dimension of the input. Padding in batch dimension and channel dimension should be [0, 0] or (0, 0).

        The default value is 0.
    dilation (int|list|tuple, optional): The dilation size. If dilation is a list/tuple, it must
        contain one integer, (dilation_size). Default: 1.
    groups (int, optional): The groups number of the conv1d function. According to grouped
        convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
        the first half of the filters is only connected to the first half
        of the input channels, while the second half of the filters is only
        connected to the second half of the input channels. Default: 1.
    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: `"NCL"`, `"NLC"`.
        The default is `"NCL"`. When it is `"NCL"`, the data is stored in the order of:
        `[batch_size, input_channels, feature_length]`.
    name(str, optional): For detailed information, please refer
       to :ref:`api_guide_Name`. Usually name is no need to set and
       None by default.

Returns:
    A tensor representing the conv1d, whose data type is the
    same with input.

Examples:
    .. code-block:: python

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

        >>> x = paddle.to_tensor([[[4, 8, 1, 9],
        ...                        [7, 2, 0, 9],
        ...                        [6, 9, 2, 6]]], dtype="float32")
        >>> w = paddle.to_tensor([[[9, 3, 4],
        ...                        [0, 0, 7],
        ...                        [2, 5, 6]],
        ...                       [[0, 3, 4],
        ...                        [2, 9, 7],
        ...                        [5, 6, 8]]], dtype="float32")

        >>> y = F.conv1d(x, w)
        >>> print(y)
        Tensor(shape=[1, 2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[133., 238.],
        [160., 211.]]])
TFNCLNLCzHAttr(data_format) should be 'NCL' or 'NLC'. Received Attr(data_format): .r   r5   r*   NHWCNCHWr   >Input x should be 3D tensor, but received x with the shape of r   z'The groups of conv1d should not be zeroSThe channel of input must be divisible by groups,received: the channel of input is , the shape of input is , the groups is UThe number of filters must be divisible by groups,received: the number of filters is , the shape of weight is r:   zBThe size of padding's dimension should be 1 or 2. But got padding=r   r   )assigncpur`   rT   rW   rb   re   r0   rg   ri   rj   rR   rk   rm   rn   )r   rK   rL   ry   r   rQ   r   tensor.creationr   paddledevice
get_devicer   rg   astyper   r   r   r   rT   rW   r   r   r   r~   r   r   r   r   )rR   r   r   r   r6   r   r\   r_   r   cudnn_versionr]   r7   r   conv2d_data_formatnum_channelsnum_filtersrP   paddle_assignfloat16_convertl_typesqueeze_axisr   rp   rr   r   r   rq   s                              r1   conv1dr   '  s#   p &'M 		.(++6-q:
 	

 %'L$"!K#/V
177|qLQWWIV
 	
 77;'L,,q/K{BCC!lb0Vr\11=>VWXW^W^V_vh(
 	

 q kR/FbL22=>WX^XdXdWevh(
 	
 "4G1!MG
7|qa"'"	W	-w-PQXPYZ
 	
 7/&!X67F=OHa<=H: O}}!U*<<6>>)"O]]177+F

fnn <"O;;qww'D6"FvRD)FF 	"A&!+#	%22L!<.)AX--!"	C ))!"C  d=C36(3!"/4!2-	
 	!w98	
 V0vx0""C"877>cU#u 	 	
  d=C
#\N
+Cjj(Jr3   c	                r   US;  a  [        SU S35      eUS:H  n	U	(       a  SOSn
[        U R                  5      S:w  a  [        SU R                   35      eU R                  U
   nUR                  S	   nUS	:X  a  [        S
5      eX-  S	:w  a9  [        5       (       d  US:w  a$  US:w  a  [        SU SU R                   SU 35      eX-  S	:w  a9  [        5       (       d  US:w  a$  US:w  a  [        SU SUR                   SU 35      e[	        5       n[        5       (       a  Ub  SOSn[        XIS5      u  pO[        USS5      n[        USS5      nSnX:X  a'  US:w  a!  X-  S	:X  a  Sn[        5       (       a  SnGOiSnGOe[        5       (       GaU  [        R                  " U UUUUUUU5      nUGb2  U
S	:  a  U
[        U R                  5      -   OU
n
[        UR                  5      [        U R                  5      :  at  [        R                  " U[        U
5       Vs/ s H  nSPM     snUR                  -   [        [        U R                  5      U
-
  S-
  5       Vs/ s H  nSPM     sn-   5      n[        5       S   (       aI  S[        5       ;   a;  [        5          [        R                   " US5      nUR#                  U5        SSS5        [        R$                  " UU5      $ U$ [        5       (       a  ['        S5      S   (       a  Sn[)        U UUUUUUUUU
UUU5      $ s  snf s  snf ! , (       d  f       Nl= f)a  

The convolution2D layer calculates the output based on the input, filter
and strides, paddings, dilations, groups parameters. Input and
Output are in NCHW or NHWC format, where N is batch size, C is the number of
channels, H is the height of the feature, and W is the width of the feature.
Filter is in MCHW format, where M is the number of output image channels,
C is the number of input image channels, H is the height of the filter,
and W is the width of the filter. If the groups is greater than 1,
C will equal the number of input image channels divided by the groups.
Please refer to UFLDL's `convolution
<http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/>`_
for more details.
If bias attribution and activation type are provided, bias is added to the
output of the convolution, and the corresponding activation function is
applied to the final result.

For each input :math:`X`, the equation is:

..  math::

    Out = \sigma (W \ast X + b)

Where:

* :math:`X`: Input value, a tensor with NCHW or NHWC format.
* :math:`W`: Filter value, a tensor with MCHW format.
* :math:`\\ast`: Convolution operation.
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
* :math:`\\sigma`: Activation function.
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

Example:

    - Input:

      Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`

      Filter shape: :math:`(C_{out}, C_{in}, H_f, W_f)`

    - Output:

      Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`

    Where

    ..  math::

        H_{out}&= \frac{(H_{in} + 2 * paddings[0] - (dilations[0] * (H_f - 1) + 1))}{strides[0]} + 1 \\\\
        W_{out}&= \frac{(W_{in} + 2 * paddings[1] - (dilations[1] * (W_f - 1) + 1))}{strides[1]} + 1

.. note::
    Alias Support: The parameter name ``input`` can be used as an alias for ``x``.

Args:
    x (Tensor): The input is 4-D Tensor with shape [N, C, H, W], the data type
        of input is float16 or float32 or float64.
        Alias: ``input``.
    weight (Tensor): The convolution kernel with shape [M, C/g, kH, kW], where M is
        the number of output channels, g is the number of groups, kH is the filter's
        height, kW is the filter's width.
    bias (Tensor, optional): The bias with shape [M,].
    stride (int|list|tuple, optional): The stride size. It means the stride in convolution.
        If stride is a list/tuple, it must contain two integers, (stride_height, stride_width).
        Otherwise, stride_height = stride_width = stride. Default: stride = 1.
    padding (string|int|list|tuple, optional): The padding size. It means the number of zero-paddings
        on both sides for each dimension.If `padding` is a string, either 'VALID' or
        'SAME' which is the padding algorithm. If padding size is a tuple or list,
        it could be in three forms: `[pad_height, pad_width]` or
        `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`, and when
        `data_format` is `"NCHW"`, `padding` can be in the form `[[0,0], [0,0],
        [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
        when `data_format` is `"NHWC"`, `padding` can be in the form
        `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
        Default: padding = 0.
    dilation (int|list|tuple, optional): The dilation size. It means the spacing between the kernel
        points. If dilation is a list/tuple, it must contain two integers, (dilation_height,
        dilation_width). Otherwise, dilation_height = dilation_width = dilation.
        Default: dilation = 1.
    groups (int, optional): The groups number of the Conv2D Layer. According to grouped
        convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
        the first half of the filters is only connected to the first half
        of the input channels, while the second half of the filters is only
        connected to the second half of the input channels. Default: groups=1.
    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: `"NCHW"`, `"NHWC"`.
        The default is `"NCHW"`. When it is `"NCHW"`, the data is stored in the order of:
        `[batch_size, input_channels, input_height, input_width]`.
    name(str, optional): For detailed information, please refer
       to :ref:`api_guide_Name`. Usually name is no need to set and
       None by default.

Returns:
    A Tensor representing the conv2d result, whose data type is the same with input.

Examples:
    .. code-block:: pycon

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

        >>> x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
        >>> w_var = paddle.randn((6, 3, 3, 3), dtype='float32')

        >>> y_var = F.conv2d(x_var, w_var)

        >>> print(y_var.shape)
        paddle.Size([2, 6, 6, 6])
r   r   zJAttr(data_format) should be 'NCHW' or 'NHWC'. Received Attr(data_format): r   r   r5   r*      >Input x should be 4D tensor, but received x with the shape of r   z+The groups of conv2d should be not be zero.r   r   r   r   r   NTFr:   r   r   rT   rW   rU   rV   r   FLAGS_conv2d_disable_cudnn)rK   rL   ry   r   r   r   rQ   r   r   r   rT   r   ranger
   r   r   rz   r{   r|   r   r   )rR   r   r   r   r6   r   r\   r_   r   r7   r   r   r   r   r]   rP   r   r   ir   s                       r1   rT   rT   -  sp   t **++6-q:
 	

 &(L$"!K
177|qLQWWIV
 	
 77;'L,,q/K{FGG!lb0Vr\11=>VWXW^W^V_vh(
 	

 q kR/FbL22=>WX^XdXdWevh(
 	
 &'M "##(A 	  "4G1!MGVQ1FxJ7HFA&!+# ""II}}!	H  #Q  #agg,.$ 
 tzz?S\1!>>$)+$67$6q$67**%&+CL;,F,J&KL&K1&KLMD "O$>?!;!== '-':': !( %??E	 #
 zz(D11 	23(
 		 5 8L #s   L
L#)L((
L6c                J   [        5       nUb  SnOSnU	S;  a  [        SU	 S35      eU	S:H  nU(       a  SOSn[        U R                  5      S	:w  a  [        S
U R                   35      eU R                  U   nUS:X  a  [        S5      eX-  S:w  a9  [	        5       (       d  US:w  a$  US:w  a  [        SU SU R                   SU 35      e[        XMS5      u  nn[        U5      S:X  a	  / UQSPSPnO$[        U5      S:X  a  / UQSPnO[        SU 35      e/ [        USS5      QSPn/ [        USS5      QSPnUc  / nONUS:w  a  [        S5      e[        U[        [        [        45      (       a  / [        USS5      QSPnO[        S5      eUS:X  a  / nO/ [        USS5      QSPn[        U5      S:  a#  US   US   :  a  [        SUS    SUS    35      e[        UR                  5      S	:w  a  [        SUR                   35      eSnUR                  S   nX:X  a  US:w  a  US:X  a  U(       d  SnSnU(       a  SOSnU(       a  SOSn[        U U/S 9n [        US/S 9n[        5       (       a-  [        [        U5      " U UUUUUUUUU5
      nUb
  [        UX.S 9nO{U /U/S!.nUUUUUUUUUS".	n[!        U S#/ S$QS5        [#        U40 [%        5       D6nUR'                  S%S&9nUR)                  U5      nS'U/0nUR+                  UUUUS(9  Ub
  [        UX.S 9n[-        UU/S 9nU$ ))a  
The 1-D convolution transpose layer calculates the output based on the input,
filter, and dilation, stride, padding. Input(Input) and output(Output)
are in 'NCL' format or 'NLC' where N is batch size, C is the number of channels,
L is the length of the feature. The details of convolution transpose
layer, please refer to the following explanation and references
`therein <https://arxiv.org/pdf/1603.07285.pdf>`_.
If bias attribution and activation type are provided, bias is added to
the output of the convolution, and the corresponding activation function
is applied to the final result.

For each input :math:`X`, the equation is:

.. math::

    Out = \sigma (W \ast X + b)

Where:

* :math:`X`: Input value, a 3-D Tensor with 'NCL' format or 'NLC' format.
* :math:`W`: Filter value, a 3-D Tensor with 'MCK' format.
* :math:`\\ast`: Convolution operation.
* :math:`b`: Bias value, a 2-D Tensor with shape [M, 1].
* :math:`\\sigma`: Activation function.
* :math:`Out`: Output value, a 3-D Tensor with data format 'NCL' or 'NLC', the shape of :math:`Out` and :math:`X` may be different.

Example:

    - Input:

      Input shape: :math:`(N, C_{in}, L_{in})`

      Filter shape: :math:`(C_{in}, C_{out}, L_f)`

    - Output:

      Output shape: :math:`(N, C_{out}, L_{out})`

    Where

    .. math::

       L^\prime_{out} &= (L_{in} - 1) * stride - 2 * padding + dilation * (L_f - 1) + 1 \\
       L_{out} &\in [ L^\prime_{out}, L^\prime_{out} + stride ]

Note:
      The conv1d_transpose can be seen as the backward of the conv1d. For conv1d,
      when stride > 1, conv1d maps multiple input shape to the same output shape,
      so for conv1d_transpose, when stride > 1, input shape maps multiple output shape.
      If output_size is None, :math:`L_{out} = L^\prime_{out}`;
      else, the :math:`L_{out}` of the output size must between :math:`L^\prime_{out}`
      and :math:`L^\prime_{out} + stride`.

Args:
    x(Tensor): 3-D tensor with [N, C, L] or [N, L, C] format,
                     its data type is float32 or float64.
    weight(Tensor): The convolution kernel, a Tensor with shape [C, M/g, K],
        where M is the number of output channels(filters), g is the number of groups,
        K is the size of the kernel.
    bias(Tensor, optional): The bias, a Tensor with shape [M, ].
    stride(int|tuple|list, optional): The stride size. It means the stride in transposed convolution.
        If stride is a list/tuple, it must contain one integer, `(stride_size)`.
        Default: stride = 1.
    padding(int|list|str|tuple, optional): The padding size. The padding argument effectively adds
         `dilation * (kernel - 1)` amount of zero-padding on both sides of input. If `padding` is a
         string, either 'VALID' or 'SAME' supported, which is the padding algorithm.
         If `padding` is a tuple or list, it could be in two forms:
         `[pad]` or `[pad_left, pad_right]`. Default: padding = 0.
    output_padding(int|list|tuple, optional): The count of zeros to be added to tail of each dimension.
         If it is a list/tuple, it must contain one integer. Default: 0.
    groups(int, optional): The groups number of the conv1d transpose function. Inspired by
        grouped convolution in Alex Krizhevsky's Deep CNN paper, in which
        when group=2, the first half of the filters is only connected to the
        first half of the input channels, while the second half of the
        filters is only connected to the second half of the input channels.
        Default: groups = 1.
    dilation(int|tuple|list, optional): The dilation size. It means the spacing between the kernel points.
        If dilation is a list/tuple, it must contain one integer, `(dilation_size)`.
        Default: dilation = 1.
    output_size(int|tuple|list, optional): The output image size. If output size is a
        tuple/list, it must contain one integer, `(feature_length)`. None if use
        filter_size(shape of weight), padding, and stride to calculate output_size.
    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: `"NCL"`, `"NLC"`.
        The default is `"NCL"`. When it is `"NCL"`, the data is stored in the order of:
        `[batch_size, input_channels, input_length]`.
    name(str, optional): For detailed information, please refer
       to :ref:`api_guide_Name`. Usually name is no need to set and
       None by default.

Returns:
    A tensor representing the result of 1-D transpose convolution, whose
    data type is the same with input. And its shape is (num_batches, channels, length)
    when data_format is `"NCL"` and (num_batches, length, channels) when data_format is
    `"NLC"`.

Examples:
    .. code-block:: python

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

        >>> # shape: (1, 2, 4)
        >>> x = paddle.to_tensor([[[4, 0, 9, 7],
        >>>                       [8, 0, 9, 2,]]], dtype="float32")
        >>> # shape: (2, 1, 2)
        >>> w = paddle.to_tensor([[[7, 0]],
        >>>                       [[4, 2]]], dtype="float32")

        >>> y = F.conv1d_transpose(x, w)
        >>> print(y)
        Tensor(shape=[1, 1, 5], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[60., 16., 99., 75., 4. ]]])
TFr   @Attr(data_format) of conv2d_transpose got wrong value: received z(, but only 'NCL' or 'NLC' are supported.r   r5   r*   r   r   r   z2The groups of conv1d_transpose should not be zero.Sthe channel of input must be divisible by groups,received: the channel of input is r   r   r:   z?The size of padding's dimension should 1 or 2. But got padding=r   r   <output_padding option is mutually exclusive with output_sizeoutput_size1output_size should be int, or list, tuple of intsoutput_paddingzTThe size of output_padding should not be greater than stride.But got output_padding=z and stride=zHInput weight should be 3D tensor, but received weight with the shape of conv2d_transposedepthwise_conv2d_transposer   r   r   r`   rb   	r   r   rY   rZ   rP   r[   r\   r]   r_   r0   r   rR   rk   rm   rn   )r   rK   rL   ry   r   rQ   r   r-   r.   r/   rM   r   r   r}   r   r   r   r   r~   r   r   r   r   )rR   r   r   r   r6   r   r\   r   r   r_   r   r   r]   r7   r   r   rP   r   r   r   r   r   rp   rr   r   r   rq   s                              r1   conv1d_transposer   "  s   ~ &'M 		.(#}$LN
 	
 %'L$"!K
177|qLQWWIV
 	
 77;'L{MNN!lb0Vr\11=>VWXW^W^V_vh(
 	
 "4G1!MG
7|q"G"Q""	W	G-Q-MgYW
 	
 8vq(37Q7F=1j9=1=HQN  kD%#566NOKMJNANKC  
^Q0@A


 >Q>!#4vay#@&&4Q&7%8VAYKQ
 	

 6<<AVW]WcWcVde
 	
 !G,,q/KA1.	%22L#/V!<.)AvRD)Ffg&
  d=C36(3,&!2!"-

 	!w9;M	
 W11""C"877>cU# 	 	
  d=C
#\N
+CJr3   c                   U	S;  a  [        SU	 S35      eU	S:H  nU(       a  SOSn[        U R                  5      S:w  a  [        SU R                   35      e[        UR                  5      S:w  a  [        S	UR                   35      eU R                  U   nUS
:X  a  [        S5      eX-  S
:w  a9  [        5       (       d  US:w  a$  US:w  a  [        SU SU R                   SU 35      e[	        5       n[        5       (       a  Ub  SOSn[        XKS5      u  nn[        USS5      n[        USS5      nUc  / nGO$US
:w  a  [        S5      e[        U[        [        45      (       a*  [        U5      (       a  [        U5      nO[        USS5      nO[        U[        5      (       a  [        USS5      nO[        U[        [        R                   45      (       a{  [#        UR$                  SSS/S5        [        UR                  5      S:X  a=  UR                  S
   S:X  d  UR                  S
   S:X  a  UR                  S
   S:X  a  X/nO[        S5      e[        S5      eUS
:X  a  / nO[        USS5      nSnUR                  S   nX:X  a  US:w  a
  US:X  a  SnSn['        5       (       aF  US:X  a  [(        R*                  O[(        R,                  nU" U UUUUUUUUU	5
      nUb
  [/        UX,S9$ U$ U /U/S.nUUUUUUUUU	S.	n[1        U S / S!QS5        [3        U40 [5        5       D6nUR7                  U R$                  5      nS"U/0nUR9                  UUUUS#9  Ub  UR7                  U R$                  5      n[        UR                  5      n[        UR                  5      nUS:X  d  [        U5      [        U5      :X  a  UR9                  S$U/U/S%.S&U/0S'S0S#9  U$ [        U5      [        U5      :  d   S(5       e[        U5      [        U5      -
  U-
  n[;        US/U-  U-   S/U-  -   5      nUR9                  S$U/U/S%.S&U/0S'S0S#9   U$ UnU$ ))aP  

The convolution2D transpose layer calculates the output based on the input,
filter, and dilations, strides, paddings. Input(Input) and output(Output)
are in NCHW or NHWC format. Where N is batch size, C is the number of channels,
H is the height of the feature, and W is the width of the feature.
Parameters(dilations, strides, paddings) are two elements. These two elements
represent height and width, respectively. The details of convolution transpose
layer, please refer to the following explanation and references
`therein <https://arxiv.org/pdf/1603.07285.pdf>`_.
If bias attribution and activation type are provided, bias is added to
the output of the convolution, and the corresponding activation function
is applied to the final result.
See more detail in :ref:`api_paddle_nn_Conv2DTranspose` .

For each input :math:`X`, the equation is:

..  math::

    Out = \sigma (W \ast X + b)

Where:

* :math:`X`: Input value, a 4-D Tensor with NCHW or NHWC format.
* :math:`W`: Filter value, a 4-D Tensor with MCHW format.
* :math:`\\ast`: Convolution operation.
* :math:`b`: Bias value, a 2-D Tensor with shape [M, 1].
* :math:`\\sigma`: Activation function.
* :math:`Out`: Output value, a 4-D Tensor with data format 'NCHW' or 'NHWC', the shape of :math:`Out` and :math:`X` may be different.

Example:

    - Input:

      Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`

      Filter shape: :math:`(C_{in}, C_{out}, H_f, W_f)`

    - Output:

      Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`

    Where

    ..  math::

       H^\prime_{out} &= (H_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (H_f - 1) + 1 \\
       W^\prime_{out} &= (W_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (W_f - 1) + 1 \\
       H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[0] ] \\
       W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[1] ]

Note:
      The conv2d_transpose can be seen as the backward of the conv2d. For conv2d,
      when stride > 1, conv2d maps multiple input shape to the same output shape,
      so for conv2d_transpose, when stride > 1, input shape maps multiple output shape.
      If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`;
      else, the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}`
      and :math:`H^\prime_{out} + strides[0]`, and the :math:`W_{out}` of the output size must
      between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]`.

Args:
    x(Tensor): 4-D Tensor with [N, C, H, W] or [N, H, W, C] format,
        whose data type is float32 or float64.
    weight(Tensor): The convolution kernel, a Tensor with shape [C, M/g, kH, kW],
        where M is the number of output channels(filters), g is the number of groups,
        kH is the height of the kernel, and kW is the width of the kernel.
    bias(Tensor, optional): The bias, a Tensor with shape [M, ].
    stride(int|list|tuple, optional): The stride size. It means the stride in transposed convolution.
        If stride is a list/tuple, it must contain two integers, (stride_height, stride_width).
        Otherwise, stride_height = stride_width = stride. Default: stride = 1.
    padding(str|int|list|tuple, optional): The padding size. It means the number of zero-paddings
        on both sides for each dimension. If `padding` is a string, either 'VALID' or
        'SAME' which is the padding algorithm. If padding size is a tuple or list,
        it could be in three forms: `[pad_height, pad_width]` or
        `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`,
        and when `data_format` is `"NCHW"`, `padding` can be in the form
        `[[0,0], [0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
        when `data_format` is `"NHWC"`, `padding` can be in the form
        `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
        Default: padding = 0.
    output_padding(int|list|tuple, optional): Additional size added to one side
        of each dimension in the output shape. Default: 0.
    groups(int, optional): The groups number of the Conv2D transpose layer. Inspired by
        grouped convolution in Alex Krizhevsky's Deep CNN paper, in which
        when group=2, the first half of the filters is only connected to the
        first half of the input channels, while the second half of the
        filters is only connected to the second half of the input channels.
        Default: groups = 1.
    dilation(int|list|tuple, optional): The dilation size. It means the spacing between the kernel points.
        If dilation is a list/tuple, it must contain two integers, (dilation_height, dilation_width).
        Otherwise, dilation_height = dilation_width = dilation. Default: dilation = 1.
    output_size(int|tuple|list, optional): The output image size. If output size is a
        tuple/list, it must contain two integers, (image_height, image_width). None if use
        filter_size(shape of weight), padding, and stride to calculate output_size.
    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: `"NCHW"`, `"NHWC"`.
        The default is `"NCHW"`. When it is `"NCHW"`, the data is stored in the order of:
        `[batch_size, input_channels, input_height, input_width]`.
    name(str, optional): For detailed information, please refer
       to :ref:`api_guide_Name`. Usually name is no need to set and
       None by default.

Returns:
    A Tensor representing the conv2d_transpose, whose
    data type is the same with input and shape is (num_batches, channels, out_h,
    out_w) or (num_batches, out_h, out_w, channels). The tensor variable storing
    transposed convolution result.

Examples:
    .. code-block:: pycon

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

        >>> x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
        >>> w_var = paddle.randn((3, 6, 3, 3), dtype='float32')

        >>> y_var = F.conv2d_transpose(x_var, w_var)

        >>> print(y_var.shape)
        paddle.Size([2, 6, 10, 10])
r   r   z*, but only 'NCHW' or 'NHWC' are supported.r   r5   r*   r   r   zHInput weight should be 4D tensor, but received weight with the shape of r   z2The groups of conv2d_transpose should not be zero.r   r   r   TFr:   r   r   r   r   int32int64r   z-output_size must contain one or two integers.zDoutput_size should be int or Tensor or list, tuple of ints or Tensorr   r   r`   rb   r   rR   rf   rm   rn   rs   rt   rw   ra   rx   )rK   rL   ry   r   r   r   rQ   r   r-   r.   r/   r   r   rM   r   r	   Valuer   r   r   r   r   r   r   r   r   r~   r   r   r   )rR   r   r   r   r6   r   r   r\   r   r_   r   r7   r   r   r   r]   rP   r   r   opr   rp   rr   r   rq   r   r   r   s                               r1   r   r   .  s   P **#}$NP
 	
 &(L$"!K
177|qLQWWIV
 	
 6<<AVW]WcWcVde
 	
 77;'L{MNN!lb0Vr\11=>VWXW^W^V_vh(
 	
 &'M "##(A 	  "4G1!MGVQ1FxJ7HQN  kD%=11K((5kB-k1mLS)))+q-HKh		%:;;!!'""	 ;$$%*!!!$)[->->q-AQ-F$$Q'1,#."<K C  V  (<LM G,,q/K,!"3q8H.	 ,, ##22 	
 
 !(DCCO36(3,&!2!"&

 	!7		
 W11<<QWWEhZ( 	 	
 ;;AGGDC8>>*G4::&Gb CLCL$@  *"*4&9"SEN!2,	 ! . J! 7|c'l2 Q2 g,W5C1#+g5gE   *"*4&9"SEN!2,	 !  J CJr3   c	                   US;  a  [        SU S35      eUS:H  n	U	(       a  SOSn
[        U R                  5      S:w  a  [        SU R                   35      eU R                  U
   nUR                  S	   nUS	:X  a  [        S
5      eX-  S	:w  a-  [        5       (       d  US:w  a  US:w  a  [        SU SU S35      eX-  S	:w  a-  [        5       (       d  US:w  a  US:w  a  [        SU SU S35      e[	        5       n[        5       (       a  Ub  SOSn[        XIS5      u  pO[        USS5      n[        USS5      nSn[        U UUUUUUUUU
UUU5      $ )a  

The convolution3D layer calculates the output based on the input, filter
and strides, paddings, dilations, groups parameters. Input(Input) and
Output(Output) are in NCDHW or NDHWC format. Where N is batch size C is the number of
channels, D is the depth of the feature, H is the height of the feature,
and W is the width of the feature. Convolution3D is similar with Convolution2D
but adds one dimension(depth). If bias attribution and activation type are
provided, bias is added to the output of the convolution, and the
corresponding activation function is applied to the final result.

For each input :math:`X`, the equation is:

..  math::

    Out = \sigma (W \ast X + b)

In the above equation:

* :math:`X`: Input value, a tensor with NCDHW or NDHWC format.
* :math:`W`: Filter value, a tensor with MCDHW format.
* :math:`\\ast`: Convolution operation.
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
* :math:`\\sigma`: Activation function.
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

Example:

    - Input:

      Input shape: :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`

      Filter shape: :math:`(C_{out}, C_{in}, D_f, H_f, W_f)`

    - Output:
      Output shape: :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`

    Where

    ..  math::

        D_{out}&= \frac{(D_{in} + 2 * paddings[0] - (dilations[0] * (D_f - 1) + 1))}{strides[0]} + 1 \\
        H_{out}&= \frac{(H_{in} + 2 * paddings[1] - (dilations[1] * (H_f - 1) + 1))}{strides[1]} + 1 \\
        W_{out}&= \frac{(W_{in} + 2 * paddings[2] - (dilations[2] * (W_f - 1) + 1))}{strides[2]} + 1

.. note::
    Alias Support: The parameter name ``input`` can be used as an alias for ``x``.

Args:
    x (Tensor): The input is 5-D Tensor with shape [N, C, D, H, W], the data
        type of input is float16 or float32 or float64.
        Alias: ``input``.
    weight (Tensor): The convolution kernel, a Tensor with shape [M, C/g, kD, kH, kW],
        where M is the number of filters(output channels), g is the number of groups,
        kD, kH, kW are the filter's depth, height and width respectively.
    bias (Tensor, optional): The bias, a Tensor of shape [M, ].
    stride (int|list|tuple, optional): The stride size. It means the stride in convolution. If stride is a
        list/tuple, it must contain three integers, (stride_depth, stride_height, stride_width).
        Otherwise, stride_depth = stride_height = stride_width = stride. Default: stride = 1.
    padding (string|int|list|tuple, optional): The padding size. It means the number of zero-paddings
        on both sides for each dimension. If `padding` is a string, either 'VALID' or
        'SAME' which is the padding algorithm. If padding size is a tuple or list,
        it could be in three forms: `[pad_depth, pad_height, pad_width]` or
        `[pad_depth_front, pad_depth_back, pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`,
        and when `data_format` is `"NCDHW"`, `padding` can be in the form
        `[[0,0], [0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
        when `data_format` is `"NDHWC"`, `padding` can be in the form
        `[[0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
        Default: padding = 0.
    dilation (int|list|tuple, optional): The dilation size. It means the spacing between the kernel points.
        If dilation is a list/tuple, it must contain three integers, (dilation_depth, dilation_height,
        dilation_width). Otherwise, dilation_depth = dilation_height = dilation_width = dilation.
        Default: dilation = 1.
    groups (int, optional): The groups number of the Conv3D Layer. According to grouped
        convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
        the first half of the filters is only connected to the first half
        of the input channels, while the second half of the filters is only
        connected to the second half of the input channels. Default: groups=1
    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: `"NCDHW"`, `"NDHWC"`.
        The default is `"NCDHW"`. 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): For detailed information, please refer
       to :ref:`api_guide_Name`. Usually name is no need to set and
       None by default.

Returns:
    A Tensor representing the conv3d, whose data type is
    the same with input. If act is None, the tensor storing the
    convolution result, and if act is not None, the tensor storing
    convolution and non-linearity activation result.

Examples:
    .. code-block:: pycon

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

        >>> x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
        >>> w_var = paddle.randn((6, 3, 3, 3, 3), dtype='float32')

        >>> y_var = F.conv3d(x_var, w_var)

        >>> print(y_var.shape)
        paddle.Size([2, 6, 6, 6, 6])
NCDHWNDHWCLAttr(data_format) should be 'NCDHW' or 'NDHWC'. Received Attr(data_format): r   r   r5   r*      >Input x should be 5D tensor, but received x with the shape of r   z%The groups of conv3d should not be 0.]The number of input channels must be divisible by Attr(groups). Received: number of channels(
), groups().zUThe number of filters must be divisible by Attr(groups). Received: number of filters(TFr   r   r   rX   )	rK   rL   ry   r   r   r   rQ   r   r   )rR   r   r   r   r6   r   r\   r_   r   r7   r   r   r   r   r]   rP   r   s                    r1   rX   rX   \  s   n ,,""-a1
 	

 ')L$"!K
177|qLQWWIV
 	
 77;'L,,q/K{@AA!lb0Vr\,,8>F82O
 	
 q kR/FbL++6-z&M
 	

 &'M "##(A 	  "4G1!MGVQ1FxJ7HG	 r3   c                   U	S;  a  [        SU	 S35      eU	S:H  nU(       a  SOSn[        U R                  5      S:w  a  [        SU R                   35      e[        UR                  5      S:w  a  [        S	UR                   35      eU R                  U   nUS
:X  a  [        S5      eX-  S
:w  a-  [        5       (       d  US:w  a  US:w  a  [        SU SU S35      e[	        XKS5      u  pN[        USS5      n[        USS5      nUc  / nOJUS
:w  a  [        S5      e[        U[        [        [        45      (       a  [        USS5      nO[        S5      eUS
:X  a  / nO[        USS5      n[        5       n[        5       (       a  Ub  SOSnSnU(       a  SOSn[        5       (       a.  [        R                  " U UUUUUUUUU5
      nUb
  [        UX,S9$ U$ U /U/S.nUUUUUUUUUS.	n[!        U40 [#        5       D6n[%        U S/ SQS 5        UR'                  U R(                  5      nS!U/0nUR+                  UUUUS"9  Ub  [        UX,S9nU$ UnU$ )#aL  
The convolution3d transpose layer calculates the output based on the input,
filter, and dilations, strides, paddings. Input(Input) and output(Output)
are in NCDHW or NDHWC format. Where N is batch size, C is the number of channels,
D is the depth of the feature, H is the height of the feature, and W
is the width of the feature. Parameters(dilations, strides, paddings) are
two elements. These two elements represent height and width, respectively.
The details of convolution transpose layer, please refer to the following
explanation and references `therein <https://arxiv.org/pdf/1603.07285.pdf>`_.
If bias attribution and activation type are provided, bias is added to
the output of the convolution, and the corresponding activation function
is applied to the final result.
See more detail in :ref:`api_paddle_nn_Conv3DTranspose` .

For each input :math:`X`, the equation is:

..  math::

    Out = \sigma (W \ast X + b)

In the above equation:

* :math:`X`: Input value, a Tensor with NCDHW or NDHWC format.
* :math:`W`: Filter value, a Tensor with NCDHW format.
* :math:`\ast`: Convolution operation.
* :math:`b`: Bias value, a 2-D Tensor with shape [M, 1].
* :math:`\sigma`: Activation function.
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

Example:

    - Input:

      Input shape: :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`

      Filter shape: :math:`(C_{in}, C_{out}, D_f, H_f, W_f)`

    - Output:

      Output shape: :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`

    Where

    ..  math::

       D^\prime_{out} &= (D_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (D_f - 1) + 1 \\
       H^\prime_{out} &= (H_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (H_f - 1) + 1 \\
       W^\prime_{out} &= (W_{in} - 1) * strides[2] - 2 * paddings[2] + dilations[2] * (W_f - 1) + 1 \\
       D_{out} &\in [ D^\prime_{out}, D^\prime_{out} + strides[0] ] \\
       H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[1] ] \\
       W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[2] ]

Note:
    The conv3d_transpose can be seen as the backward of the conv3d. For conv3d,
    when stride > 1, conv3d maps multiple input shape to the same output shape,
    so for conv3d_transpose, when stride > 1, input shape maps multiple output shape.
    If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`;
    else, the :math:`D_{out}` of the output size must between :math:`D^\prime_{out}` and
    :math:`D^\prime_{out} + strides[0]`, the :math:`H_{out}` of the output size must
    between :math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[1]`, and the
    :math:`W_{out}` of the output size must between :math:`W^\prime_{out}` and
    :math:`W^\prime_{out} + strides[2]`.

Args:
    x (Tensor): The input is 5-D Tensor with shape [N, C, D, H, W] or [N, D, H, W, C], the data type
        of input is float32 or float64.
    weight (Tensor): The convolution kernel, a Tensor with shape [C, M/g, kD, kH, kW],
        where M is the number of filters (output channels), g is the number of groups,
        kD, kH, kW are the filter's depth, height and width respectively.
    bias (Tensor, optional): The bias, a Tensor of shape [M, ]. Default: None.
    stride (int|list|tuple, optional): The stride size. It means the stride in transposed convolution.
        If stride is a list/tuple, it must contain three integers, (stride_depth, stride_height,
        stride_width). Otherwise, stride_depth = stride_height = stride_width = stride.
        Default: 1.
    padding (str|int|list|tuple, optional): The padding size. It means the number of zero-paddings
        on both sides for each dimension. If `padding` is a string, either 'VALID' or
        'SAME' which is the padding algorithm. If padding size is a tuple or list,
        it could be in three forms: `[pad_depth, pad_height, pad_width]` or
        `[pad_depth_front, pad_depth_back, pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`,
        and when `data_format` is `"NCDHW"`, `padding` can be in the form
        `[[0,0], [0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
        when `data_format` is `"NDHWC"`, `padding` can be in the form
        `[[0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
        Default: 0.
    output_padding (int|list|tuple, optional): Additional size added to one side
        of each dimension in the output shape. Default: 0.
    groups (int, optional): The groups number of the Conv3D transpose layer. Inspired by
        grouped convolution in `Alex Krizhevsky's Deep CNN paper <https://papers.nips.cc/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf>`_, in which
        when groups = 2, the first half of the filters is only connected to the
        first half of the input channels, while the second half of the
        filters is only connected to the second half of the input channels.
        Default: 1.
    dilation (int|list|tuple, optional): The dilation size. It means the spacing between the kernel points.
        If dilation is a list/tuple, it must contain three integers, (dilation_depth, dilation_height,
        dilation_width). Otherwise, dilation_depth = dilation_height = dilation_width = dilation.
        Default: 1.
    output_size (int|list|tuple, optional): The output image size. If output size is a
        list/tuple, it must contain three integers, (image_depth, image_height, image_width).
        None if use filter_size(shape of weight), padding, and stride to calculate output_size.
    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: `"NCHW"`, `"NHWC"`.
        When it is `"NCHW"`, the data is stored in the order of: `[batch_size, input_channels, input_height, input_width]`.
        Default: `"NCHW"`.
    name (str, optional): For detailed information, please refer
       to :ref:`api_guide_Name`. Usually name is no need to set.
       Default: None.

Returns:
    A Tensor representing the conv3d_transpose, whose data
    type is the same with input and shape is (num_batches, channels, out_d, out_h,
    out_w) or (num_batches, out_d, out_h, out_w, channels). If act is None, the tensor
    variable storing the transposed convolution result, and if act is not None, the tensor
    variable storing transposed convolution and non-linearity activation result.

Examples:
    .. code-block:: pycon

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

        >>> x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
        >>> w_var = paddle.randn((3, 6, 3, 3, 3), dtype='float32')

        >>> y_var = F.conv3d_transpose(x_var, w_var)

        >>> print(y_var.shape)
        paddle.Size([2, 6, 10, 10, 10])
r   r   r   r   r5   r*   r   r   zHInput weight should be 5D tensor, but received weight with the shape of r   z2The groups of conv3d_transpose should not be zero.r   r   r   r   r   r   r   r   r   r   TFconv3d_transposer   r   r`   rb   )	r   r   rZ   rP   rY   r[   r\   r]   r_   rR   r   rX   rm   rn   )rK   rL   ry   r   rQ   r   r-   r.   r/   rM   r   r   r   r   r   r   r   r~   r   r   r   r   )rR   r   r   r   r6   r   r\   r   r   r_   r   r7   r   r   rP   r   r]   r   data_format_r   rp   rr   r   rq   r   s                            r1   r   r     s   \ ,,""-a1
 	

 ')L$"!K
177|qLQWWIV
 	
 6<<AVW]WcWcVde
 	
 77;'L{MNN!lb0Vr\,,8>F82O
 	

 "4G1!MGVQ1FxJ7HQN  kD%#566)+q-HKC  (<LM%'M
 "##(A 	  !G)6vL**
 !(DCCO36(3,&!2!"'

 W11 s5x	
 <<QWWEhZ( 	 	
  4BC J CJr3   )Nr*   r   Nr*   r*   r   r*   rT   TN)rR   r    r   r    r   Tensor | Noner   int | Sequence[int]r6   z8_PaddingSizeMode | int | Sequence[int] | Sequence[Size2]r   r   r\   rM   r_   r$   r   rM   r   rI   r]   boolr   
str | Nonereturnr    )Nr*   r   r*   r*   r   N)rR   r    r   r    r   r   r   r%   r6   2_PaddingSizeMode | Size1 | Size2 | Sequence[Size2]r   r%   r\   rM   r_   r!   r   r   r   r    )Nr*   r   r*   r*   r   N)rR   r    r   r    r   r   r   r&   r6   2_PaddingSizeMode | Size2 | Size4 | Sequence[Size2]r   r&   r\   rM   r_   r"   r   r   r   r    )	Nr*   r   r   r*   r*   Nr   N)rR   r    r   r    r   r   r   r%   r6   r   r   r%   r\   rM   r   r%   r   zSize1 | Noner_   r!   r   r   r   r    )	Nr*   r   r   r*   r*   Nr   N)rR   r    r   r    r   r   r   r&   r6   r   r   r&   r   r&   r\   rM   r   zSize2 | Noner_   r"   r   r   r   r    )Nr*   r   r*   r*   r   N)rR   r    r   r    r   r   r   r'   r6   2_PaddingSizeMode | Size3 | Size6 | Sequence[Size2]r   r'   r\   rM   r_   r#   r   r   r   r    )	Nr*   r   r   r*   r*   Nr   N)rR   r    r   r    r   r   r   r'   r6   r   r   r'   r\   rM   r   r'   r   zSize3 | Noner_   r#   r   r   r   r    )E
__future__r   typingr   r   r   r   r   r   r	   paddle.base.frameworkr
   r   paddle.devicer   r   r   paddle.tensor.manipulationr   paddle.tensor.mathr   paddle.utils.decorator_utilsr   base.data_feederr   r   base.layer_helperr   common_ops_importr   r   r   	frameworkr   tensor.manipulationr   r   utilsr   r   r   r   collections.abcr   r    paddle._typingr!   r"   r#   r$   r%   r&   r'   r(   r)   commonr+   __all__r2   r8   r?   rQ   r   r   rT   r   r   rX   r   r;   r3   r1   <module>r      s   #    I I G 
 / - < E , ) '   5  (
 
 
 ) ,I1&n "#HI$% &]]] ]  	]
 F] "] ] ] ] ] ] ] ]@ cG9%& BC %BBB B 	B
 @B B B B B B 'BJ cG9%& BC &qqq q 	q
 @q q q q q q 'qn BC $ %III I 	I
 @I I I I I I I I^ BC $ &kkk k 	k
 @k k k k k k k k\	 cG9%& BC 'ppp p 	p
 @p p p p p p 'pl BC $ 'zzz z 	z
 @z z z z z z z zr3   