+
    åûj«‡  ã                  ób  a € 0 t $ ^ RIHt ^ RIt^ RIHtHtHt ^ RIt^ RI	H
u Ht ^ RIH
t
 ^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHtHtHtHt R	 R
 lt ! R R]
P6                  4      t ! R R]
P6                  4      t ! R R]
P<                  4      t ! R R]
P<                  4      t  ! R R]
P<                  4      t! ! R R]
P6                  4      t" ! R R]
P<                  4      t# ! R R]
P<                  4      t$ ! R R]
P<                  4      t% ! R R]
P<                  4      t&RR ]! R!R"4      R#.R$]! R!R%4      R&./R'R ]! R!R(4      R).R$]! R!R*4      R+./R,R ]! R!R-4      R..R$]! R!R/4      R0.R1]! R!R24      R3.R4]! R!R54      R6.//t'R7](R8&   R9 R: lt)RAR; R< llt*RAR= R> llt+R1RBR4RC/t,RAR? R@ llt-R# )Dé    )ÚannotationsN)ÚAnyÚOptionalÚSequence)Únn)Ú
checkpoint)ÚKORNIA_CHECKÚKORNIA_CHECK_SAME_SIZE)Úhf_urlÚload_state_dict_from_url)ÚDropPathÚLayerNorm2dÚwindow_partitionÚwindow_unpartitionc               ó    € V ^8„  d   QhRRRR/# )é   Úxúint | tuple[int, int]Úreturnútuple[int, int]© )Úformats   "ÚRC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\models\tiny_vit.pyÚ__annotate__r   $   s   € ÷ /ñ /Ð'ð /¨Oñ /ó    c                ó8   € \        V \        4      '       d   W 3# T # ©N)Ú
isinstanceÚint)r   s   &r   Ú
_make_pairr    $   s   € Ü ¤3×'Ò'ˆAˆ6Ð.¨QÐ.r   c                  óR   a € ] tR t^(tRt^^ ^]P                  3R V 3R llltRtV ;t	# )ÚConvBNaÑ  Implement a sequential block containing a convolution followed by Batch Normalization.

Args:
    in_channels: The number of input channels.
    out_channels: The number of output channels.
    kernel_size: The size of the convolving kernel. Default: 1.
    stride: The stride of the convolution. Default: 1.
    padding: The zero-padding added to both sides of the input. Default: 0.
    groups: The number of blocked connections from input to output. Default: 1.
c               ó8   € V ^8„  d   QhRRRRRRRRRRRRRR	R
R/# )r   Úin_channelsr   Úout_channelsÚkernel_sizeÚstrideÚpaddingÚgroupsÚ
activationútype[nn.Module]r   ÚNoner   )r   s   "r   r   ÚConvBN.__annotate__4   sZ   € ÷  ñ  àð ð ð ð ð	 ð
 ð ð ð ð ð ð $ð ð 
ñ r   c           
     	ó°   <€ \         SV `  4        \        P                  ! WW4WVR R7      V n        \        P
                  ! V4      V n        V! 4       V n        R# )F)r)   ÚbiasN)ÚsuperÚ__init__r   ÚConv2dÚcÚBatchNorm2dÚbnÚact)	Úselfr$   r%   r&   r'   r(   r)   r*   Ú	__class__s	   &&&&&&&&€r   r1   ÚConvBN.__init__4   s@   ø€ ô 	‰ÑÔÜ—’˜;°kÈ7ÐhmÔnˆŒÜ—.’. Ó.ˆŒÙ“<ˆŽr   )r6   r5   r3   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚIdentityr1   Ú__static_attributes__Ú__classcell__©r8   s   @r   r"   r"   (   s)   ø† ñ	ð  ØØØ&(§k¡k÷ ÷  ð  r   r"   c                  óL   a € ] tR t^DtRt]P                  3R V 3R llltRtV ;t	# )Ú
PatchEmbedaX  Perform patch embedding using a series of convolutions.

This module divides the input image into patches and projects them into
the embedding dimension.

Args:
    in_channels: The number of input image channels.
    embed_dim: The dimension of the resulting embeddings.
    activation: The activation layer to use. Default: :class:`nn.GELU`.
c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r$   r   Ú	embed_dimr*   r+   r   r,   r   )r   s   "r   r   ÚPatchEmbed.__annotate__P   s)   € ÷ 
ñ 
 Cð 
°Cð 
À_ð 
Ðcgñ 
r   c                	ó¶   <€ \         SV `  4        \        P                  ! \	        W^,          ^^^4      V! 4       \	        V^,          V^^^4      4      V n        R# )r   N)r0   r1   r   Ú
Sequentialr"   Úseq)r7   r$   rF   r*   r8   s   &&&&€r   r1   ÚPatchEmbed.__init__P   sL   ø€ Ü‰ÑÔÜ—=’=Ü�;¨Q¥°°1°aÓ8¹*»,ÌÈyÐ\]Í~Ð_hÐjkÐmnÐpqÓHró
ˆŽr   )rJ   ©
r:   r;   r<   r=   r>   r   ÚGELUr1   r@   rA   rB   s   @r   rD   rD   D   s$   ø† ñ	ð XZ×W^ÑW^÷ 
÷ 
ð 
r   rD   c                  óZ   a € ] tR t^WtRt]P                  R3R V 3R llltR R ltRt	V ;t
# )ÚMBConvaz  Implement the Mobile Inverted Residual Bottleneck Convolution layer.

Args:
    in_channels: The number of input channels.
    out_channels: The number of output channels.
    expansion: The expansion ratio for the hidden dimension.
    kernel_size: The convolution kernel size.
    stride: The stride of the convolution.
    dropout: The dropout rate for the stochastic depth.
ç        c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   r$   r   r%   Úexpansion_ratioÚfloatr*   r+   Ú	drop_pathr   r,   r   )r   s   "r   r   ÚMBConv.__annotate__c   sF   € ÷  ñ  àð ð ð ð ð	 ð
 $ð ð ð ð 
ñ r   c           	     	óî   <€ \         SV `  4        \        W,          4      p\        W^VR7      V n        \        Wf^^^Wd4      V n        \        Wb^4      V n        \        V4      V n        V! 4       V n	        R# )é   ©r*   N)
r0   r1   r   r"   Úconv1Úconv2Úconv3r   rT   r6   )r7   r$   r%   rR   r*   rT   Úhidden_channelsr8   s   &&&&&& €r   r1   ÚMBConv.__init__c   sd   ø€ ô 	‰ÑÔÜ˜kÕ;Ó<ˆÜ˜K¸!È
ÔSˆŒ
Ü˜O¸aÀÀAÀÓcˆŒ
Ü˜O¸1Ó=ˆŒ
Ü! )Ó,ˆŒÙ“<ˆŽr   c               ó    € V ^8„  d   QhRRRR/# ©r   r   ztorch.Tensorr   r   )r   s   "r   r   rU   s   s   € ÷ Sñ S˜ð S¨,ñ Sr   c                ó¨   € V P                  WP                  V P                  V P                  V P	                  V4      4      4      4      ,           4      # )a†  Apply the MBConv residual block to a feature map.

Args:
    x: Feature map tensor with shape ``(B, C, H, W)``, where
        :math:`B` is batch size, :math:`C` is channels, :math:`H` is
        height, and :math:`W` is width.

Returns:
    Tensor with the same shape as ``x`` after pointwise expansion,
    depthwise convolution, projection, stochastic depth, and residual
    activation.
)r6   rT   r[   rZ   rY   ©r7   r   s   &&r   ÚforwardÚMBConv.forwards   s9   € ð �x‰x˜ŸN™N¨4¯:©:°d·j±jÀÇÁÈAÃÓ6OÓ+PÓQÕQÓRÐRr   )r6   rY   rZ   r[   rT   ©r:   r;   r<   r=   r>   r   rM   r1   rb   r@   rA   rB   s   @r   rO   rO   W   s*   ø† ñ	ð  ')§g¡gØ÷ ò  ÷ Só Sr   rO   c                  óX   a € ] tR t^ƒtRt]P                  3R V 3R llltR R ltRt	V ;t
# )ÚPatchMerginga  Implement the patch merging layer for downsampling in TinyViT.

Args:
    input_resolution: The height and width of the input feature map.
    dim: The number of input channels.
    out_dim: The number of output channels.
    act: The activation function class. Default: nn.GELU.
c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   Úinput_resolutionr   Údimr   Úout_dimr'   r*   r+   r   r,   r   )r   s   "r   r   ÚPatchMerging.__annotate__�   sF   € ÷ 1ñ 1à/ð1ð ð1ð ð	1ð
 ð1ð $ð1ð 
ñ1r   c           
     	óF  <€ \        VR9   R4       \        SV `	  4        \        V4      V n        V P                  ^ ,          V,          V P                  ^,          V,          3V n        \        W#^VR7      V n        \        W3^V^W5R7      V n        \        W3^4      V n	        R# )rW   zstride must be either 1 or 2rX   )r)   r*   N)rW   r   )
r	   r0   r1   r    rh   Úoutput_resolutionr"   rY   rZ   r[   )r7   rh   ri   rj   r'   r*   r8   s   &&&&&&€r   r1   ÚPatchMerging.__init__�   s�   ø€ ô 	�V˜vÑ%Ð'EÔFÜ‰ÑÔÜ *Ð+;Ó <ˆÔà"&×"7Ñ"7¸Õ":¸fÕ"DÀd×F[ÑF[Ð\]ÕF^ÐbhÕFhÐ!iˆÔÜ˜C¨!¸
ÔCˆŒ
Ü˜G¨a°¸À7ÔbˆŒ
Ü˜G¨aÓ0ˆŽ
r   c               ó    € V ^8„  d   QhRRRR/# r_   r   )r   s   "r   r   rk   ž   s   € ÷ ,ñ ,˜ð ,¨,ñ ,r   c                ó"  € VP                   ^8X  d-   VP                  ^^4      P                  ^V P                  4      pV P	                  V P                  V P                  V4      4      4      p\        VP                  RR 4      V P                  8w  d]   \        RVP                  R,           RVP                  R,           RV P                  ^ ,           RV P                  ^,           R2	4      hVP                  ^4      P                  ^^4      # )a  Merge or project patch tokens for TinyViT downsampling.

Args:
    x: Either token tensor with shape ``(B, H * W, C)`` or feature
        map tensor with shape ``(B, C, H, W)``.

Returns:
    Token tensor with shape :math:`(B, H_{out} * W_{out}, C_{out})`.
    The spatial size is reduced when this layer was configured with
    stride ``2``.

Raises:
    ValueError: if :math:`(H_{out}, W_{out})` is not the grid the next stage is built for: the input of a
        :class:`TinyViT` is not ``img_size`` (the first patch merging reads the image's own grid from a
        ``(B, C, H, W)`` map), or ``img_size`` is not a multiple of 32 (of 16 with ``mobile_sam=True``),
        so the stride-2 convolution rounds an odd grid up where the stages were built for it rounded down.
NzThe input gives a r   z6 token grid, but the TinyViT stages are built for the zf grid of an img_size x img_size image (img_size must be a multiple of 32, of 16 with mobile_sam=True).éþÿÿÿéÿÿÿÿ)ÚndimÚ	transposeÚ	unflattenrh   r[   rZ   rY   ÚtupleÚshaperm   Ú
ValueErrorÚflattenra   s   &&r   rb   ÚPatchMerging.forwardž   sè   € ð$ �6‰6�QŒ;Ø—‘˜A˜qÓ!×+Ñ+¨A¨t×/DÑ/DÓEˆAØ�J‰J�t—z‘z $§*¡*¨Q£-Ó0Ó1ˆÜ�—‘˜˜�Ó $×"8Ñ"8Ô8ÜØ$ Q§W¡W¨R¥[ M°°1·7±7¸2µ;°-Ð?uØ×)Ñ)¨!Õ,Ð-¨Q¨t×/EÑ/EÀaÕ/HÐ.Ið JSðSóð ð
 �y‰y˜‹|×%Ñ% a¨Ó+Ð+r   )rY   rZ   r[   rh   rm   rd   rB   s   @r   rf   rf   ƒ   s%   ø† ñð ')§g¡g÷1ò 1÷",ó ,r   rf   c                  ó`   a € ] tR t^¼tRt]P                  RRRR3R V 3R llltR R	 ltR
t	V ;t
# )Ú	ConvLayera1  Implement a convolutional layer with optional checkpointing and downsample.

Args:
    dim: The number of input channels.
    depth: The number of blocks in the convolutional layer.
    activation: The activation function to use. Default: :class:`nn.GELU`.
    drop_path: The dropout rate for the stochastic depth. Default: 0.0.
    downsample: The downsample module to use. Default: None.
    use_checkpoint: Whether to use checkpointing for memory efficiency. Default: False.
    conv_expand_ratio: The expansion ratio for the hidden dimension. Default: 4.0.
rP   NFç      @c               ó8   € V ^8„  d   QhRRRRRRRRRR	R
RRRRR/# )r   ri   r   Údepthr*   r+   rT   úfloat | list[float]Ú
downsampleúOptional[nn.Module]Úuse_checkpointÚboolÚconv_expand_ratiorS   r   r,   r   )r   s   "r   r   ÚConvLayer.__annotate__É   sZ   € ÷ %ñ %àð%ð ð%ð $ð	%ð
 'ð%ð (ð%ð ð%ð !ð%ð 
ñ%r   c                	ó  <€ \         S	V `  4        W`n        \        V\        4      '       g   V.V,          p\
        P                  ! \        V4       Uu. uF  p\        WWsWH,          4      NK  	  up4      V n	        WPn
        R # u upi r   )r0   r1   rƒ   r   Úlistr   Ú
ModuleListÚrangerO   Úblocksr�   )
r7   ri   r   r*   rT   r�   rƒ   r…   Úir8   s
   &&&&&&&& €r   r1   ÚConvLayer.__init__É   st   ø€ ô 	‰ÑÔØ,Ôô ˜)¤T×*Ò*Ø"˜ eÕ+ˆIÜ—m’mÜTYÐZ_ÔT`ÓaÑT`ÈqŒV�CÐ/¸Y½\ÖJÑT`Ñaó
ˆŒð
 %Žùò	 bs   ÁBc               ó    € V ^8„  d   QhRRRR/# r_   r   )r   s   "r   r   r†   à   s   € ÷ ñ ˜ð ¨,ñ r   c                óÊ   € V P                    F3  pV P                  '       d   \        P                  ! W!4      MV! V4      pK5  	  V P                  e   V P                  V4      pV# )a  Apply a sequence of convolutional TinyViT blocks.

Args:
    x: Feature tensor passed through the layer blocks.

Returns:
    Tensor after all MBConv blocks and the optional downsample module.
    The output may be a token tensor when downsampling is configured.
©r‹   rƒ   r   r�   ©r7   r   Úblks   && r   rb   ÚConvLayer.forwardà   sP   € ð —;”;ˆCØ15×1D×1DÐ1D”
×%Ò% cÔ-É#ÈaË&ŠAñ à�?‰?Ò&Ø—‘ Ó"ˆAØˆr   ©r‹   r�   rƒ   rd   rB   s   @r   r|   r|   ¼   s1   ø† ñ
ð  ')§g¡gØ),Ø*.Ø$Ø#&÷%ò %÷.ó r   r|   c                  óN   a € ] tR t^ñtRt]P                  R3R V 3R llltRtV ;t	# )ÚMLPaP  Implement a multi-layer perceptron (MLP) with optional dropout.

Args:
    in_features: The number of input features.
    hidden_features: The number of hidden features.
    out_features: The number of output features.
    activation: The activation function to use. Default: :class:`nn.GELU`.
    drop: The dropout rate. Default: 0.0.
rP   c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   Úin_featuresr   Úhidden_featuresÚout_featuresr*   r+   ÚdroprS   r   r,   r   )r   s   "r   r   ÚMLP.__annotate__ü   sF   € ÷ &ñ &àð&ð ð&ð ð	&ð
 $ð&ð ð&ð 
ñ&r   c                	óJ  <€ \         SV `  4        \        P                  ! V4      V n        \        P
                  ! W4      V n        V! 4       V n        \        P                  ! V4      V n	        \        P
                  ! W#4      V n
        \        P                  ! V4      V n        R # r   )r0   r1   r   Ú	LayerNormÚnormÚLinearÚfc1Úact1ÚDropoutÚdrop1Úfc2Údrop2)r7   r˜   r™   rš   r*   r›   r8   s   &&&&&&€r   r1   ÚMLP.__init__ü   si   ø€ ô 	‰ÑÔÜ—L’L Ó-ˆŒ	Ü—9’9˜[Ó:ˆŒÙ“LˆŒ	Ü—Z’Z Ó%ˆŒ
Ü—9’9˜_Ó;ˆŒÜ—Z’Z Ó%ˆŽ
r   )r¢   r¤   r¦   r¡   r¥   rŸ   rL   rB   s   @r   r–   r–   ñ   s#   ø† ñð ')§g¡gØ÷&÷ &ð &r   r–   c                  óX   a € ] tR tRtRtR
R V 3R lllt]R R l4       tR R ltR	t	V ;t
# )Ú	Attentioni  aj  Implement an attention mechanism with optional relative position encoding.

Args:
    dim: The number of input channels.
    key_dim: The dimension of the key.
    num_heads: The number of attention heads. Default: 8.
    attn_ratio: The ratio of the attention dimension. Default: 4.0.
    resolution: The resolution of the input feature map. Default: (14, 14).
c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   ri   r   Úkey_dimÚ	num_headsÚ
attn_ratiorS   Ú
resolutionr   r   r,   r   )r   s   "r   r   ÚAttention.__annotate__  sF   € ÷ /ñ /àð/ð ð/ð ð	/ð
 ð/ð $ð/ð 
ñ/r   c                	ó”  <€ \         S	V `  4        W0n        VR,          V n        W n        W#,          V n        \        WB,          4      V n        \        WB,          4      V,          V n        W@n	        V P                  V P
                  ^,          ,           p\        P                  ! V4      V n        \        P                  ! W4      V n        \        P                  ! V P                  V4      V n        V P!                  V4      w  rx\        P"                  ! \$        P&                  ! W84      4      V n        V P+                  RVRR7       V  R# )ç      à?Úattention_bias_idxsF)Ú
persistentNg      à¿)r0   r1   r¬   Úscaler«   Únh_kdr   ÚdÚdhr­   r   rž   rŸ   r    ÚqkvÚprojÚbuild_attention_biasÚ	ParameterÚtorchÚzerosÚattention_biasesÚregister_buffer)
r7   ri   r«   r¬   r­   r®   ÚhÚindicesÚattn_offset_sizer8   s
   &&&&&&   €r   r1   ÚAttention.__init__  sé   ø€ ô 	‰ÑÔØ"ŒØ˜d•]ˆŒ
ØŒØÕ(ˆŒ
Ü�ZÕ)Ó*ˆŒÜ�jÕ*Ó+¨iÕ7ˆŒØ$ŒØ�G‰G�d—j‘j 1•nÕ$ˆä—L’L Ó%ˆŒ	Ü—9’9˜SÓ$ˆŒÜ—I’I˜dŸg™g sÓ+ˆŒ	à$(×$=Ñ$=¸jÓ$IÑ!ˆÜ "§¢¬U¯[ª[¸Ó-UÓ VˆÔØ×ÑÐ2°GÈÐÔNÛr   c               ó    € V ^8„  d   QhRRRR/# )r   r®   r   r   ztuple[torch.Tensor, int]r   )r   s   "r   r   r¯   7  s   € ÷ )ñ )¨ð )Ð=Uñ )r   c                óî  € V w  r\         P                  ! V4      p\         P                  ! V4      pVP                  V4      pVP                  V4      pVR,          VR,          ,
          P	                  4       pVR,          VR,          ,
          P	                  4       pWr,          V,           p	\         P
                  ! V	RR7      w  r«VP                  W,          W,          4      pV
P                  4       pWÍ3# )aA  Build lookup indices for relative attention bias.

Args:
    resolution: Window resolution ``(H, W)`` used by the attention
        block.

Returns:
    Tuple ``(indices, size)``. ``indices`` maps each token pair in the
    window to a relative-position bias entry, and ``size`` is the
    number of unique bias entries.
T)Úreturn_inverse)ºNNNN)NrÇ   )r¼   ÚarangeÚrepeat_interleaveÚrepeatÚabsÚuniqueÚviewÚnumel)r®   ÚHÚWÚrowsÚcolsÚrrÚccÚdrÚdcÚkeysÚunique_keysÚinverserÁ   rÂ   s   &             r   rº   ÚAttention.build_attention_bias6  sÂ   € ð ‰ˆÜ�|Š|˜A‹ˆÜ�|Š|˜A‹ˆØ×#Ñ# AÓ&ˆØ�[‰[˜‹^ˆØ��k˜B˜w�KÕ'×,Ñ,Ó.ˆØ��k˜B˜w�KÕ'×,Ñ,Ó.ˆØ�v˜�{ˆÜ$Ÿ|š|¨DÀÔFÑˆØ—,‘,˜q�u a¥eÓ,ˆØ&×,Ñ,Ó.ÐØÐ(Ð(r   c               ó    € V ^8„  d   QhRRRR/# r_   r   )r   s   "r   r   r¯   P  s   € ÷ ñ ˜ð ¨,ñ r   c                óz  € VP                   w  r#pV P                  V4      pV P                  V4      pVP                  RV P                  R34      P                  ^ ^^^4      pVP                  V P                  V P                  V P                  .^R7      w  rgpV P                  RV P                  3,          p	WgP                  RR4      ,          V P                  ,          V	,           p
V
P                  RR7      p
W¨,          P                  ^^4      P                  W#V P                  4      pV P!                  V4      # )a1  Apply relative-position self-attention to token features.

Args:
    x: Token tensor with shape ``(B, N, C)``, where :math:`B` is
        batch size, :math:`N` is number of tokens, and :math:`C` is
        embedding dimension.

Returns:
    Tensor with shape ``(B, N, C)`` after attention and projection.
)ri   rÇ   rr   rq   )rw   rŸ   r¸   ru   r¬   ÚpermuteÚsplitr«   r¶   r¾   r²   rt   r´   ÚsoftmaxÚreshaper·   r¹   )r7   r   ÚBÚNÚ_r¸   ÚqÚkÚvr/   Úattns   &&         r   rb   ÚAttention.forwardP  sý   € ð —'‘'‰ˆˆaØ�I‰I�a‹LˆØ�h‰h�q‹kˆØ�m‰m˜B §¡°Ð 4Ó5×=Ñ=¸aÀÀAÀqÓIˆØ—)‘)˜TŸ\™\¨4¯<©<¸¿¹Ð@Àa�)ÓH‰ˆˆaà×$Ñ$ Q¨×(@Ñ(@Ð%@ÕAˆØ—K‘K  BÓ'Õ'¨4¯:©:Õ5¸Õ<ˆà�|‰| ˆ|Ó#ˆØ�X× Ñ   AÓ&×.Ñ.¨q°T·W±WÓ=ˆØ�y‰y˜‹|Ðr   )r¾   r­   r¶   r·   r«   rµ   rŸ   r¬   r¹   r¸   r´   )é   r}   )é   rê   )r:   r;   r<   r=   r>   r1   Ústaticmethodrº   rb   r@   rA   rB   s   @r   r©   r©     s0   ø† ñ÷/ò /ð6 ô)ó ð)÷2ó r   r©   c                  ób   a € ] tR tRtRt^RRR^]P                  3R V 3R llltR R ltR	t	V ;t
# )
ÚTinyViTBlockii  ao  Implement a single block of the TinyViT architecture.

This block consists of multi-head self-attention and a feed-forward network
with residual connections.

Args:
    dim: The input dimension size.
    input_resolution: The height and width of the input feature map.
    num_heads: The number of attention heads.
    window_size: The size of the local attention window.
    mlp_ratio: The ratio of MLP hidden dimension to embedding dimension.
    drop: The dropout rate. Default: 0.0.
    drop_path: The stochastic depth rate. Default: 0.0.
    layer_scale_init_value: The initial value for layer scaling. Default: 1e-5.
r}   rP   c               ó@   € V ^8„  d   QhRRRRRRRRRRR	RR
RRRRRRR/
# )r   ri   r   rh   r   r¬   Úwindow_sizeÚ	mlp_ratiorS   r›   rT   Úlocal_conv_sizer*   r+   r   r,   r   )r   s   "r   r   ÚTinyViTBlock.__annotate__z  sn   € ÷ .ñ .àð.ð 0ð.ð ð	.ð
 ð.ð ð.ð ð.ð ð.ð ð.ð $ð.ð 
ñ.r   c
                	ól  <€ \        W,          ^ 8H  R4       \        SV `	  4        \        V4      V n        W@n        W,          p
\        WVRWD34      V n        \        V4      V n	        \        WV^V^,          V4      V n        \        V\        W,          4      WV4      V n        \        V4      V n        R# )r   z!dim must be divislbe by num_headsg      ð?N)r	   r0   r1   r    rh   rï   r©   rç   r   Ú
drop_path1r"   Ú
local_convr–   r   ÚmlpÚ
drop_path2)r7   ri   rh   r¬   rï   rð   r›   rT   rñ   r*   Úhead_dimr8   s   &&&&&&&&&& €r   r1   ÚTinyViTBlock.__init__z  sŸ   ø€ ô 	�S•_¨Ñ)Ð+NÔOÜ‰ÑÔÜ *Ð+;Ó <ˆÔØ&ÔØÕ#ˆä˜c¨Y¸¸kÐ=WÓXˆŒ	Ü" 9Ó-ˆŒÜ  ¨?¸A¸ÐRSÕ?SÐUXÓYˆŒÜ�sœC ¥Ó0°#À4ÓHˆŒÜ" 9Ó-ˆŽr   c               ó    € V ^8„  d   QhRRRR/# r_   r   )r   s   "r   r   rò   ’  s   € ÷ 0ñ 0˜ð 0¨,ñ 0r   c                ó˜  € V P                   w  r#VP                  w  rEpTpVP                  WBW64      p\        WP                  4      w  rV P                  VP                  ^^4      4      P                  ^V P                  V P                  34      p\        WP                  W‚V34      pVP                  WEV4      pWpP                  V4      ,           pVP                  ^^4      P                  WFW#4      pV P                  V4      pVP                  WFV4      P                  ^^4      pWP                  V P                  V4      4      ,           # )a*  Apply one TinyViT window-attention block.

Args:
    x: Token tensor with shape ``(B, H * W, C)``, where
        :math:`H` and :math:`W` match ``self.input_resolution``.

Returns:
    Tensor with the same shape as ``x`` after window attention, local
    convolution, MLP, and residual connections.
)rh   rw   rÍ   r   rï   rç   ry   ru   r   rô   rt   rà   rõ   r÷   rö   )	r7   r   rÏ   rÐ   rá   ÚLÚCÚres_xÚpad_hws	   &&       r   rb   ÚTinyViTBlock.forward’  s  € ð ×$Ñ$‰ˆØ—'‘'‰ˆˆaØˆà�F‰F�1˜ÓˆÜ$ Q×(8Ñ(8Ó9‰	ˆØ�I‰I�a—i‘i  1“oÓ&×0Ñ0°°T×5EÑ5EÀt×GWÑGWÐ4XÓYˆÜ˜q×"2Ñ"2°FÀ¸FÓCˆØ�F‰F�1˜‹Oˆà—O‘O AÓ&Õ&ˆà�K‰K˜˜1Ó×%Ñ% a¨AÓ1ˆØ�O‰O˜AÓˆØ�F‰F�1˜‹O×%Ñ% a¨Ó+ˆà—?‘? 4§8¡8¨A£;Ó/Õ/Ð/r   )rç   rô   r÷   rh   rõ   rö   rï   rd   rB   s   @r   rí   rí   i  s4   ø† ñð* ØØØØ Ø&(§g¡g÷.ò .÷00ó 0r   rí   c                  ód   a € ] tR tRtRtRRRRR^]P                  3R V 3R llltR	 R
 ltRt	V ;t
# )Ú
BasicLayeri°  ao  Implement a basic layer of the TinyViT architecture.

This layer consists of a series of TinyViT blocks, each followed by a patch
merging operation.

Args:
    dim: The input dimension size.
    input_resolution: The height and width of the input feature map.
    depth: The number of blocks in the layer.
    num_heads: The number of attention heads.
    window_size: The size of the local attention window.
    mlp_ratio: The ratio of MLP hidden dimension to embedding dimension.
    drop: The dropout rate. Default: 0.0.
    drop_path: The stochastic depth rate. Default: 0.0.
    downsample: The downsample module to use. Default: None.
    use_checkpoint: Whether to use checkpointing for memory efficiency. Default: False.
    local_conv_size: The size of the local convolution kernel. Default: 3.
    activation: The activation function to use. Default: :class:`nn.GELU`.
r}   rP   NFc               óL   € V ^8„  d   QhRRRRRRRRRRRR	R
R	RRRRRRRRRRRR/# )r   ri   r   rh   r   r   r¬   rï   rð   rS   r›   rT   r€   r�   r‚   rƒ   r„   rñ   r*   r+   r   r,   r   )r   s   "r   r   ÚBasicLayer.__annotate__Å  sŒ   € ÷ $%ñ $%àð$%ð 0ð$%ð ð	$%ð
 ð$%ð ð$%ð ð$%ð ð$%ð 'ð$%ð (ð$%ð ð$%ð ð$%ð $ð$%ð 
ñ$%r   c                	ó  <€ \         SV `  4        W n        \        P                  ! \        V4       Uu. uF4  p\        TTTTTT\        V\        4      '       d	   W�,          MTVV4	      NK6  	  up4      V n	        W�n
        R # u upi r   )r0   r1   rƒ   r   r‰   rŠ   rí   r   rˆ   r‹   r�   )r7   ri   rh   r   r¬   rï   rð   r›   rT   r�   rƒ   rñ   r*   rŒ   r8   s   &&&&&&&&&&&&& €r   r1   ÚBasicLayer.__init__Å  s‡   ø€ ô 	‰ÑÔØ,Ôä—m’mô ˜uœóñ &�Aô ØØ$ØØØØÜ$.¨y¼$×$?Ò$?�I–LÀYØ#Øö
ñ &ñó
ˆŒð$ %Žùò#s   ³:Bc               ó    € V ^8„  d   QhRRRR/# r_   r   )r   s   "r   r   r  ë  s   € ÷ ñ ˜ð ¨,ñ r   c                óÊ   € V P                    F3  pV P                  '       d   \        P                  ! W!4      MV! V4      pK5  	  V P                  e   V P                  V4      pV# )a	  Run a TinyViT stage made of several blocks.

Args:
    x: Token tensor with shape ``(B, H * W, C)``.

Returns:
    Tensor after all TinyViT blocks and optional patch merging. The
    channel count or token resolution may change if ``downsample`` is
    configured.
r�   r‘   s   && r   rb   ÚBasicLayer.forwardë  sP   € ð —;”;ˆCØ15×1D×1DÐ1D”
×%Ò% cÔ-É#ÈaË&ŠAñ à�?‰?Ò&Ø—‘ Ó"ˆAØˆr   r”   rd   rB   s   @r   r  r  °  s8   ø† ñð6 ØØ),Ø*.Ø$Ø Ø&(§g¡g÷$%ò $%÷Ló r   r  c                  óŽ   a € ] tR tRtRt^à^RRRRRRRRRR^]P                  R3R V 3R llltR	 R
 lt]	RR R ll4       t
RtV ;t# )ÚTinyViTiý  av  TinyViT model, as described in https://arxiv.org/abs/2207.10666.

The pretrained checkpoints of :meth:`from_config` were trained on images normalized with the ImageNet mean and
standard deviation, so a :math:`[0, 1]` image goes in as
``kornia.enhance.normalize(image, torch.tensor([0.485, 0.456, 0.406]), torch.tensor([0.229, 0.224, 0.225]))``.

Args:
    img_size: Size of the square input image, a multiple of 32 (of 16 with ``mobile_sam=True``). The attention
        stages are built for the token grid of an ``img_size`` image (see :meth:`forward`).
    in_chans: Number of input image's channels.
    num_classes: Number of output classes.
    embed_dims: List of embedding dimensions.
    depths: List of block count for each downsampling stage
    num_heads: List of attention heads used in self-attention for each downsampling stage.
    window_sizes: List of self-attention's window size for each downsampling stage.
    mlp_ratio: Ratio of MLP dimension to embedding dimension in self-attention.
    drop_rate: Dropout rate.
    drop_path_rate: Stochastic depth rate.
    use_checkpoint: Whether to use activation checkpointing to trade compute for memory.
    mbconv_expand_ratio: Expansion ratio used in MBConv block.
    local_conv_size: Kernel size of convolution used in TinyViTBlock
    activation: activation function.
    mobile_sam: Whether to use modifications for MobileSAM.

iè  r}   rP   Fc                óX   € V ^8„  d   QhRRRRRRRRRRRRR	RR
RRRRRRRRRRRRRRRRR/# )r   Úimg_sizer   Úin_chansÚnum_classesÚ
embed_dimszSequence[int]Údepthsr¬   Úwindow_sizesrð   rS   Ú	drop_rateÚdrop_path_raterƒ   r„   Úmbconv_expand_ratiorñ   r*   r+   Ú
mobile_samr   r,   r   )r   s   "r   r   ÚTinyViT.__annotate__  s¼   € ÷ W;ñ W;àðW;ð ðW;ð ð	W;ð
 "ðW;ð ðW;ð !ðW;ð $ðW;ð ðW;ð ðW;ð ðW;ð ðW;ð #ðW;ð ðW;ð  $ð!W;ð" ð#W;ð$ 
ñ%W;r   c                	ó¸  <€ \         S V `  4        Wn        Wðn        V  V'       do   . ROp\        P
                  ! \        P                  ! VR,          R^RR7      \        R4      \        P                  ! RR^^^RR7      \        R4      4      V n        M. ROpRV n        \        W$^ ,          V4      V n
        V^,          p\        P                  ! ^ V
\        V4      4       Uu. uF  pVP                  4       NK  	  pp\        V4      p. p\!        \#        WEWgV4      4       FË  w  pw  pppppV\%        V^,           \        V4      ^,
          4      ,          pVV^,
          8  d   \'        VVVVV4      MRpRVRVRV\        VRV 4      \        VRV^,            4       RVR	VR
V/pV^ 8X  d   \)        RRV/VB pM\+        RRVRVRVRVRV	RV/VB pVP-                  V4       VV,          pKÍ  	  \        P
                  ! V!  V n        VV n        \        P2                  ! VR,          4      V n        \        P6                  ! VR,          V4      V n        R# u upi )r   é   F)r/   Nri   r   rT   r�   rƒ   r*   r…   rh   r¬   rï   rð   r›   rñ   )r   r   rW   rW   rr   )r   r   r   rW   r   )r0   r1   r  r  r   rI   r2   r   ÚneckrD   Úpatch_embedr¼   ÚlinspaceÚsumÚitemÚlenÚ	enumerateÚzipÚminrf   r|   r  ÚappendÚlayersÚ	feat_sizerž   Ú	norm_headr    Úhead)!r7   r  r  r  r  r  r¬   r  rð   r  r  rƒ   r  rñ   r*   r  Ústridesrh   r   ÚdprÚn_layersr$  Úi_layerrF   r   Únum_heads_irï   r'   rj   r�   ÚkwargsÚlayerr8   s!   &&&&&&&&&&&&&&&&                €r   r1   ÚTinyViT.__init__  sl  ø€ ô& 	‰ÑÔØ ŒØ$ŒÙßò #ˆGÜŸšÜ—	’	˜* R�.¨#¨q°uÔ=Ü˜CÓ Ü—	’	˜#˜s A q¨!°%Ô8Ü˜CÓ ó	ˆD�Iò #ˆGØˆDŒIä% h¸1µ¸zÓJˆÔØ# q�=Ðô "'§¢°°>Ä3ÀvÃ;Ô!OÓPÑ!O˜Aˆq�v‰vŽxÑ!OˆÐPô �v“;ˆØˆÜMVÜ�
 I¸WÓEöN
ÑIˆGÑI�i ¨°[À&ð !¤ W¨q¥[´#°j³/ÀAÕ2EÓ!FÕGˆGð ˜h¨�lÔ*ô Ð-¨y¸'À6È:ÔVàð ð �yØ˜Ø˜S¤ V¨H¨WÐ%5Ó!6¼¸VÀMÀgÐPQÅkÐ=RÓ9SÐTØ˜jØ  .Ø˜jð&ˆFð ˜!Œ|Ü!ÑRÐ4GÐRÈ6ÑR‘ä"ñ Ø%5ðà)ðð !,ðð (ð	ð
 #ðð %4ðð ñ�ð �M‰M˜%Ô Ø Õ'Òñ?N
ô@ —m’m VÑ,ˆŒØ)ˆŒô Ÿš j°¥nÓ5ˆŒÜ—I’I˜j¨�n¨kÓ:ˆŽ	ùò[ Qs   Ã#Ic               ó    € V ^8„  d   QhRRRR/# r_   r   )r   s   "r   r   r  q  s   € ÷ ñ ˜ð ¨,ñ r   c                ój  € V P                  V4      pV P                  V4      pV P                  '       dN   VP                  ^V P                  V P                  34      P                  ^ ^^^4      pV P                  V4      pV# VP                  ^4      pV P                  V P                  V4      4      pV# )a½  Classify images if ``mobile_sam=False``, produce feature maps if ``mobile_sam=True``.

Args:
    x: images ``(B, C, H, W)`` with :math:`H = W =` ``img_size``. The strided convolutions before the
        first attention stage round up, so :math:`H` and :math:`W` from ``img_size - 7`` to ``img_size`` give
        the same token grid and run too.

Raises:
    ValueError: if the input gives a token grid other than that of an ``img_size`` image.
)
r  r$  r  ru   r%  rÝ   r  Úmeanr'  r&  ra   s   &&r   rb   ÚTinyViT.forwardq  s˜   € ð ×Ñ˜QÓˆØ�K‰K˜‹Nˆà�?�?ˆ?à—‘˜A §¡°·±Ð?Ó@×HÑHÈÈAÈqÐRSÓTˆAØ—	‘	˜!“ˆAð
 ˆð —‘�q“	ˆAØ—	‘	˜$Ÿ.™.¨Ó+Ó,ˆAØˆr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   ÚvariantÚstrÚ
pretrainedú
bool | strr-  r   r   r  r   )r   s   "r   r   r  Š  s/   € ÷ &oñ &o˜Sð &o¨jð &oÈCð &oÐT[ñ &or   c                ód   € \        V R9   R4       R\        R\        R\        /V ,          ! V3/ VB # )a
  Create a TinyViT model from pre-defined variants.

Returns the model in evaluation mode when ``pretrained`` loads the complete weights, classification head
included, and in training mode otherwise (see :ref:`pretrained-models-conventions`).

Args:
    variant: TinyViT variant. Possible values: ``'5m'``, ``'11m'``, ``'21m'``.
    pretrained: whether to use pre-trained weights. Possible values: ``False``, ``True``, ``'in22k'``,
        ``'in1k'``. For TinyViT-21M (``variant='21m'``), ``'in1k_384'``, ``'in1k_512'`` are also available;
        named, they build at the ``img_size`` you pass (224 by default), so pass ``img_size=384`` or ``512``
        to run them at their resolution.
    **kwargs: other keyword arguments that will be passed to :class:`TinyViT`. They override the variant's
        ``embed_dims``, ``depths``, ``num_heads``, ``window_sizes`` and ``drop_path_rate``.

.. note::
    ``pretrained=True`` loads the ImageNet-1k checkpoint (``'in1k'``); for TinyViT-21M it loads ``'in1k_384'``
    when ``img_size`` is at least 384 and ``'in1k_512'`` when it is at least 512. For feature extraction or
    fine-tuning, the ImageNet-22k checkpoint (``'in22k'``) is preferred.

    ``img_size`` does not change the window sizes: they are the 224-px ``[7, 7, 14, 7]`` at every
    ``img_size``, except that the TinyViT-21M ``'in1k_384'`` and ``'in1k_512'`` checkpoints get the windows
    they were trained with, ``[12, 12, 24, 12]`` and ``[16, 16, 32, 16]``, and the stochastic depth rate
    they were fine-tuned with, ``drop_path_rate=0.1`` instead of TinyViT-21M's 0.2. A ``window_sizes`` or
    ``drop_path_rate`` argument overrides them. The checkpoint's attention biases are interpolated (bicubic)
    only when the window sizes differ from the checkpoint's. ``img_size`` must be a multiple of 32 (of 16 with
    ``mobile_sam=True``), and a checkpoint's accuracy is not preserved away from the resolution it was trained
    at: on the panda image of the :doc:`/models/tiny_vit` example, TinyViT-5M's probability of the right class
    drops from 0.37 at 224 px to 0.02 at ``img_size=256``.

    With ``pretrained`` and a ``num_classes`` other than the checkpoint's, the classification head is reset to
    zeros, and the model, a pretrained backbone to fine-tune, stays in training mode. The ``'in22k'``
    checkpoints have a 21841-class head: pass ``num_classes=21841`` to get the complete model in evaluation
    mode. With the default ``num_classes=1000`` the head is reset and the model stays in training mode, so call
    ``.eval()`` before extracting features.

Ú5mÚ11mÚ21mz+Only variant 5m, 11m, and 21m are supported)r:  r;  r<  )r	   Ú_tiny_vit_5mÚ_tiny_vit_11mÚ_tiny_vit_21m)r5  r7  r-  s   &&,r   Úfrom_configÚTinyViT.from_config‰  s;   € ôL 	�WÐ 4Ñ4Ð6cÔdØ”l E¬=¸%ÄÐOÐPWÖXÐYcÑnÐgmÑnÐnr   )r%  r'  r  r$  r  r  r&  r  )é`   éÀ   é€  i   ©r   r   é   r   )é   rF  é   é   ©é   rK  rê   rK  ©F)r:   r;   r<   r=   r>   r   rM   r1   rb   rë   r@  r@   rA   rB   s   @r   r  r  ý  sc   ø† ñð8 ØØØ$7Ø ,Ø#1Ø&3ØØØ #Ø$Ø%(Ø à&(§g¡gØ ÷#W;ò W;õrð0 ö&oó ö&or   r  r:  Úin22kÚtiny_vitztiny_vit_5m_22k_distill.pthzchttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_5m_22k_distill.pthÚin1kztiny_vit_5m_22kto1k_distill.pthzghttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_5m_22kto1k_distill.pthr;  ztiny_vit_11m_22k_distill.pthzdhttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_11m_22k_distill.pthz tiny_vit_11m_22kto1k_distill.pthzhhttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_11m_22kto1k_distill.pthr<  ztiny_vit_21m_22k_distill.pthzdhttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_21m_22k_distill.pthz tiny_vit_21m_22kto1k_distill.pthzhhttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_21m_22kto1k_distill.pthÚin1k_384z$tiny_vit_21m_22kto1k_384_distill.pthzlhttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_21m_22kto1k_384_distill.pthÚin1k_512z$tiny_vit_21m_22kto1k_512_distill.pthzlhttps://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/tiny_vit_21m_22kto1k_512_distill.pthzdict[str, dict[str, list[str]]]Úurlsc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úmodelr  Úurlzstr | list[str]r   r   )r   s   "r   r   r   å  s!   € ÷ %ñ %˜Gð %¨/ð %¸gñ %r   c                óÈ  € V P                  4       p\        V4      pR V9   d
   VR ,          pV Uu. uF  pRV9   g   K  VNK  	  ppV F»  pW4,          P                  w  rgW$,          P                  w  r‰\        W4,          W$,          RV R2R7       Wy8w  g   KQ  \	        VR,          4      p
\	        V	R,          4      pW4,          P                  ^WjV
4      p\        P                  ! WËV3RR7      pVP                  W‰4      W4&   K½  	  VR,          P                  ^ ,          V P                  P                  8H  pV'       gu   R	p\        P                  ! V^R
7       \        P                  ! V P                  P                  4      VR&   \        P                  ! V P                  P                  4      VR&   V P!                  V4       V'       d   V P#                  4        V # u upi )rT  r¾   zFail to load z1: the checkpoint has a different number of heads.)Úmsgr±   Úbicubic)ÚsizeÚmodezhead.weightzaNumber of classes does not match pre-trained checkpoint's. Resetting classification head to zeros)Ú
stacklevelz	head.bias)Ú
state_dictr   rw   r
   r   rÍ   ÚFÚinterpolater'  rš   ÚwarningsÚwarnr¼   Ú
zeros_likeÚweightr/   Úload_state_dictÚeval)rT  rU  Úmodel_state_dictr\  rå   Úab_keysÚn_heads1ÚL1Ún_heads2ÚL2ÚS1ÚS2r¾   Úhead_loadedrW  s   &&             r   Ú_load_pretrainedrn  å  s—  € Ø×'Ñ'Ó)ÐÜ)¨#Ó.€Jð �*ÔØ Õ(ˆ
ñ %Ó@™*�QÐ(:¸aÑ(?�qˆq™*€GÐ@ÛˆØ!•}×*Ñ*‰ˆØ'Õ*×0Ñ0‰ˆÜØ�MÐ+Õ.°mÀAÀ3ÐFwÐ4xõ	
ð Ž8Ü�R˜•W“ˆBÜ�R˜•W“ˆBØ)�}×1Ñ1°!°XÀ2ÓFÐÜ Ÿ}š}Ð-=ÈÀHÐS\Ô]ÐØ,×1Ñ1°(Ó?ˆJ‹Mñ ð ˜]Õ+×1Ñ1°!Õ4¸¿
¹
×8OÑ8OÑO€KßØqˆÜ�Š�c aÕ(Ü$)×$4Ò$4°U·Z±Z×5FÑ5FÓ$Gˆ
�=Ñ!Ü"'×"2Ò"2°5·:±:·?±?Ó"Cˆ
�;Ñà	×Ñ˜*Ô%÷ Ø�
‰
ŒØ€Lùò7 As
   °	G¾Gc               ó$   € V ^8„  d   QhRRRRRR/# ©r   r7  r8  r-  r   r   r  r   )r   s   "r   r   r     s!   € ÷ ñ ˜Zð ¸3ð À7ñ r   c                ó>  € VP                  R . R	O4       VP                  R. R
O4       VP                  R. RO4       VP                  R. RO4       VP                  RR4       \        R/ VB pV '       d(   V RJ d   Rp \        R,          V ,          p\        W#4      pV# )r  r  r¬   r  r  rP   TrO  r:  )é@   é€   é    i@  rE  )r   é   é   é
   rJ  r   ©Ú
setdefaultr  rR  rn  ©r7  r-  rT  rU  s   &,  r   r=  r=    sŽ   € Ø
×Ñ�lÒ$7Ô8Ø
×Ñ�h¢Ô-Ø
×Ñ�k¢=Ô1Ø
×Ñ�n¢mÔ4Ø
×ÑÐ&¨Ô,ÜÑ�fÑ€EçØ˜ÓØˆJä�4�j˜Õ$ˆÜ  Ó,ˆà€Lr   c               ó$   € V ^8„  d   QhRRRRRR/# rp  r   )r   s   "r   r   r     s!   € ÷ ñ ˜jð ¸Cð ÀGñ r   c                ó>  € VP                  R . R	O4       VP                  R. R
O4       VP                  R. RO4       VP                  R. RO4       VP                  RR4       \        R/ VB pV '       d(   V RJ d   Rp \        R,          V ,          p\        W#4      pV# )r  r  r¬   r  r  çš™™™™™¹?TrO  r;  )rr  rs  r  iÀ  rE  )r   ru  ré   rê   rJ  r   rx  rz  s   &,  r   r>  r>    sŽ   € Ø
×Ñ�lÒ$7Ô8Ø
×Ñ�h¢Ô-Ø
×Ñ�k¢=Ô1Ø
×Ñ�n¢mÔ4Ø
×ÑÐ&¨Ô,ÜÑ�fÑ€EçØ˜ÓØˆJä�5�k˜*Õ%ˆÜ  Ó,ˆà€Lr   c               ó$   € V ^8„  d   QhRRRRRR/# rp  r   )r   s   "r   r   r   7  s!   € ÷ ñ ˜jð ¸Cð ÀGñ r   c                óü  € V R J d'   VP                  R^à4      pVR8¼  d   RM
VR8¼  d   RMRp RpRp\        V \        4      '       d   V \        9   d   \        V ,          pRpVP	                  R	. RO4       VP	                  R
. RO4       VP	                  R. RO4       VP	                  R\        V4      4       VP	                  RV4       \        R/ VB pV '       d    \        R,          V ,          p\        WV4      pV# )Tr  i   rQ  rD  rP  rO  gš™™™™™É?r}  r  r  r¬   r  r  r<  rJ  )rB  rC  rD  i@  rE  )rG  rF  rH  é   r   )	Úgetr   r6  Ú_TINY_VIT_21M_WINDOW_SIZESry  rˆ   r  rR  rn  )r7  r-  r  r  r  rT  rU  s   &,     r   r?  r?  7  sã   € à�TÓØ—:‘:˜j¨#Ó.ˆØ#+¨s¤?‘ZÀhÐRUÄo¹
Ð[aˆ
Ø €LØ€NÜ�*œc×"Ò" zÔ5OÔ'OÜ1°*Õ=ˆØˆà
×Ñ�lÒ$7Ô8Ø
×Ñ�h¢Ô-Ø
×Ñ�k¢>Ô2Ø
×Ñ�n¤d¨<Ó&8Ô9Ø
×ÑÐ&¨Ô7ÜÑ�fÑ€EçÜ�5�k˜*Õ%ˆÜ  Ó,ˆà€Lr   rL  )rH  rH  rI  rH  )é   rƒ  é    rƒ  ).Ú__conditional_annotations__Ú
__future__r   r_  Útypingr   r   r   r¼   Útorch.nn.functionalr   Ú
functionalr]  Útorch.utilsr   Úkornia.core.checkr	   r
   Úkornia.core.downloadr   r   Úkornia.models.commonr   r   r   r   r    rI   r"   rD   ÚModulerO   rf   r|   r–   r©   rí   r  r  rR  Ú__annotations__rn  r=  r>  r‚  r?  )r…  s   @r   Ú<module>r�     s  øð÷* #Ð "ã ß *Ñ *ã ß Ð Ý Ý "ç Bß Aß \Ó \õ/ô ˆR�]‰]ô  ô8
�—‘ô 
ô&)SˆR�Y‰Yô )SôX6,�2—9‘9ô 6,ôr2�—	‘	ô 2ôj&ˆ"�-‰-ô &ô>V�—	‘	ô VôrD0�2—9‘9ô D0ôNJ�—‘ô JôZsoˆb�i‰iô soðr 	ØÙ�:Ð<Ó=Øqð
ð 	Ù�:Ð@ÓAØuð
ð	ð 
ØÙ�:Ð=Ó>Ørð
ð 	Ù�:ÐAÓBØvð
ð	ð 
ØÙ�:Ð=Ó>Ørð
ð 	Ù�:ÐAÓBØvð
ð 	Ù�:ÐEÓFð7ð
ð 	Ù�:ÐEÓFð7ð
ð!ð+-)€Ð%ó -õ`%÷P÷$ð* )Ð*:¸JÐHXÐYÐ ÷ñ r   