
    RЦi,                     l    S SK r S SKJr   " S S\R                  5      r " S S\R                  5      rg)    Nc                   x   ^  \ rS rSr% Sr\R                  R                  \   \	S'   SS\4U 4S jjjr
S rSrU =r$ )	SpaceToDepth   zRearrange spatial dimensions into channel dimension.

Divides spatial dimensions by block_size and multiplies channels by block_size^2.
Used in TResNet as an efficient stem operation.

Args:
    block_size: Spatial reduction factor.
bs
block_sizec                 >   > [         TU ]  5         US:X  d   eXl        g )N   super__init__r   selfr   	__class__s     Y/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/timm/layers/space_to_depth.pyr   SpaceToDepth.__init__   s    Q    c                    UR                  5       u  p#pEUR                  X#X@R                  -  U R                  XPR                  -  U R                  5      nUR                  SSSSSS5      R	                  5       nUR                  X#U R                  -  U R                  -  X@R                  -  XPR                  -  5      nU$ )Nr      r         r	   sizeviewr   permute
contiguousr   xNCHWs         r   forwardSpaceToDepth.forward   s    VVX
aFF1ggtwwWWdggFIIaAq!Q'224FF1$''kDGG+Q''\1<Hr   r   )r	   )__name__
__module____qualname____firstlineno____doc__torchjitFinalint__annotations__r   r"   __static_attributes____classcell__r   s   @r   r   r      s8     			3  
 r   r   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )DepthToSpace   zRearrange channel dimension into spatial dimensions.

Inverse of SpaceToDepth. Divides channels by block_size^2 and multiplies
spatial dimensions by block_size.

Args:
    block_size: Spatial expansion factor.
c                 .   > [         TU ]  5         Xl        g )Nr
   r   s     r   r   DepthToSpace.__init__'   s    r   c                 X   UR                  5       u  p#pEUR                  X R                  U R                  X0R                  S-  -  XE5      nUR                  SSSSSS5      R	                  5       nUR                  X#U R                  S-  -  X@R                  -  XPR                  -  5      nU$ )Nr   r   r   r	   r   r   r   r   s         r   r"   DepthToSpace.forward+   s    VVX
aFF1ggtwwggl(;QBIIaAq!Q'224FF1DGGqL)1ww;GGDr   r$   )	r%   r&   r'   r(   r)   r   r"   r/   r0   r1   s   @r   r3   r3      s     r   r3   )r*   torch.nnnnModuler   r3    r   r   <module>r=      s+     299 0299 r   