
    9i                     F   S SK r S SKr S SKJs  Jr  S SK JrJr  SSKJr   SS\S\	S\
S\S	\	S
\S\4S jjr SS\S\	S\
S\S	\	S
\S\4S jjr\ R                  R                  S5         " S S\R                   5      r\ R                  R                  S5         " S S\5      rg)    N)nnTensor   )_log_api_usage_onceinputp
block_sizeinplaceepstrainingreturnc                    [         R                  R                  5       (       d2  [         R                  R                  5       (       d  [	        [
        5        US:  d  US:  a  [        SU S35      eU R                  S:w  a  [        SU R                   S35      eU(       a  US:X  a  U $ U R                  5       u  pgp[        X)U5      nUS-  S	:X  a  [        S
U S35      eX-  U	-  US-  X-
  S-   X-
  S-   -  -  -  n
[         R                  " XgX-
  S-   X-
  S-   4U R                  U R                  S9nUR                  U
5        [        R                  " XS-  /S-  S	S9n[        R                   " USX"4US-  S9nSU-
  nUR#                  5       XKR%                  5       -   -  nU(       a"  U R'                  U5      R'                  U5        U $ X-  U-  n U $ )a  
Implements DropBlock2d from `"DropBlock: A regularization method for convolutional networks"
<https://arxiv.org/abs/1810.12890>`.

Args:
    input (Tensor[N, C, H, W]): The input tensor or 4-dimensions with the first one
                being its batch i.e. a batch with ``N`` rows.
    p (float): Probability of an element to be dropped.
    block_size (int): Size of the block to drop.
    inplace (bool): If set to ``True``, will do this operation in-place. Default: ``False``.
    eps (float): A value added to the denominator for numerical stability. Default: 1e-6.
    training (bool): apply dropblock if is ``True``. Default: ``True``.

Returns:
    Tensor[N, C, H, W]: The randomly zeroed tensor after dropblock.
              ?4drop probability has to be between 0 and 1, but got .   z#input should be 4 dimensional. Got  dimensions.r   r   block size should be odd. Got  which is even.   dtypedevicevalue)r   r   stridekernel_sizepadding)torchjitis_scripting
is_tracingr   drop_block2d
ValueErrorndimsizeminemptyr   r   
bernoulli_Fpad
max_pool2dnumelsummul_)r   r   r	   r
   r   r   NCHWgammanoisenormalize_scales                Z/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torchvision/ops/drop_block.pyr%   r%   	   s   & 99!!##EII,@,@,B,BL)3w!c'OPQsRSTUUzzQ>uzzl,WXXqCxJA!ZA&JA~9*_UVV UQYJMq~/AanWXFX.YZ[EKKq~11>A3EFekkbgbnbnoE	UEE%/*Q.a8ELLvJ;S]gkl]lmEIEkkmsYY['89O

5/ L /L    c                    [         R                  R                  5       (       d2  [         R                  R                  5       (       d  [	        [
        5        US:  d  US:  a  [        SU S35      eU R                  S:w  a  [        SU R                   S35      eU(       a  US:X  a  U $ U R                  5       u  pgpn
[        X(X5      nUS-  S	:X  a  [        S
U S35      eX-  U	-  U
-  US-  X-
  S-   X-
  S-   -  X-
  S-   -  -  -  n[         R                  " XgX-
  S-   X-
  S-   X-
  S-   4U R                  U R                  S9nUR                  U5        [        R                  " XS-  /S-  S	S9n[        R                   " USX"U4US-  S9nSU-
  nUR#                  5       XLR%                  5       -   -  nU(       a"  U R'                  U5      R'                  U5        U $ X-  U-  n U $ )a  
Implements DropBlock3d from `"DropBlock: A regularization method for convolutional networks"
<https://arxiv.org/abs/1810.12890>`.

Args:
    input (Tensor[N, C, D, H, W]): The input tensor or 5-dimensions with the first one
                being its batch i.e. a batch with ``N`` rows.
    p (float): Probability of an element to be dropped.
    block_size (int): Size of the block to drop.
    inplace (bool): If set to ``True``, will do this operation in-place. Default: ``False``.
    eps (float): A value added to the denominator for numerical stability. Default: 1e-6.
    training (bool): apply dropblock if is ``True``. Default: ``True``.

Returns:
    Tensor[N, C, D, H, W]: The randomly zeroed tensor after dropblock.
r   r   r   r      z#input should be 5 dimensional. Got r   r   r   r   r      r   r      r   )r   r   r   r   )r!   r"   r#   r$   r   drop_block3dr&   r'   r(   r)   r*   r   r   r+   r,   r-   
max_pool3dr/   r0   r1   )r   r   r	   r
   r   r   r2   r3   Dr4   r5   r6   r7   r8   s                 r9   r?   r?   :   s   & 99!!##EII,@,@,B,BL)3w!c'OPQsRSTUUzzQ>uzzl,WXXqCxJJLMA!ZA)JA~9*_UVV UQY]
A1>A3E!.[\J\2]abaorsas2tuvEKK	
q~!1>A#5q~7IJRWR]R]fkfrfrE 
UEE%/*Q.a8ELLijj-Q[eij[jE IEkkmsYY['89O

5/ L /Lr:   r%   c                   h   ^  \ rS rSrSrSS\S\S\S\SS4
U 4S	 jjjrS
\	S\	4S jr
S\4S jrSrU =r$ )DropBlock2dr   z
See :func:`drop_block2d`.
r   r	   r
   r   r   Nc                 R   > [         TU ]  5         Xl        X l        X0l        X@l        g N)super__init__r   r	   r
   r   selfr   r	   r
   r   	__class__s        r9   rH   DropBlock2d.__init__w   s"    $r:   r   c                     [        XR                  U R                  U R                  U R                  U R
                  5      $ z
Args:
    input (Tensor): Input feature map on which some areas will be randomly
        dropped.
Returns:
    Tensor: The tensor after DropBlock layer.
)r%   r   r	   r
   r   r   rJ   r   s     r9   forwardDropBlock2d.forward   .     E664??DLL$((TXTaTabbr:   c                     U R                   R                   SU R                   SU R                   SU R                   S3nU$ )Nz(p=z, block_size=z
, inplace=))rK   __name__r   r	   r
   )rJ   ss     r9   __repr__DropBlock2d.__repr__   sC    ~~&&'s466(-?PPZ[_[g[gZhhijr:   )r	   r   r
   r   Fư>)rU   
__module____qualname____firstlineno____doc__floatintboolrH   r   rP   strrW   __static_attributes____classcell__rK   s   @r9   rC   rC   r   s]    % S 4 e `d  cV c c#  r:   rC   r?   c                   Z   ^  \ rS rSrSrSS\S\S\S\SS4
U 4S	 jjjrS
\	S\	4S jr
SrU =r$ )DropBlock3d   z
See :func:`drop_block3d`.
r   r	   r
   r   r   Nc                 &   > [         TU ]  XX45        g rF   )rG   rH   rI   s        r9   rH   DropBlock3d.__init__   s    5r:   r   c                     [        XR                  U R                  U R                  U R                  U R
                  5      $ rN   )r?   r   r	   r
   r   r   rO   s     r9   rP   DropBlock3d.forward   rR   r:    rY   )rU   r[   r\   r]   r^   r_   r`   ra   rH   r   rP   rc   rd   re   s   @r9   rg   rg      sR    6% 6S 64 6e 6`d 6 6cV c c cr:   rg   )FrZ   T)r!   torch.fxtorch.nn.functionalr   
functionalr,   r   utilsr   r_   r`   ra   r%   r?   fxwrapModulerC   rg   rm   r:   r9   <module>ru      s         ' ko...),.7;.JO.cg..d ko222),27;2JO2cg22j n ")) 8 n c+ cr:   