+
    åûjY&  ã                  óø   € ^ RI Ht ^ RIt^ RIHu Ht ^ RIHt  ! R R]P                  4      t ! R R]P                  4      t
 ! R R	]P                  4      t ! R
 R]P                  4      tR R ltR R ltR# )é    )ÚannotationsN)Únnc                  ó6   a € ] tR t^tRtRR V 3R llltRtV ;t# )ÚConvNormActaÆ  Apply a sequence of Convolution, Normalization, and Activation layers.

The convolution has no bias and is followed by :class:`nn.BatchNorm2d`. Its padding follows from ``kernel_size``:
``(kernel_size - 1) // 2`` on each side for an odd kernel, and for an even kernel a zero padding with one more
pixel at the bottom and right, as in PaddlePaddle.

Args:
    in_channels: Number of input channels.
    out_channels: Number of output channels.
    kernel_size: Size of the convolution kernel.
    stride: Stride of the convolution. Default: 1.
    act: Activation, ``"relu"``, ``"silu"`` or ``"none"`` (identity). Default: ``"relu"``.
    groups: Number of blocked connections from input to output. Default: 1.
    conv_naming: Attribute name of the convolution, which sets its parameter names. Default: ``"conv"``.
    norm_naming: Attribute name of the normalization layer. Default: ``"norm"``.
    act_naming: Attribute name of the activation. Default: ``"act"``.
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/
# )é   Úin_channelsÚintÚout_channelsÚkernel_sizeÚstrideÚactÚstrÚgroupsÚconv_namingÚnorm_namingÚ
act_namingÚreturnÚNone© )Úformats   "ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\models\common.pyÚ__annotate__ÚConvNormAct.__annotate__,   sn   € ÷ 1ñ 1àð1ð ð1ð ð	1ð
 ð1ð ð1ð ð1ð ð1ð ð1ð ð1ð 
ñ1ó    c
           
     	ó(  <€ \         SV `  4        V^,          ^ 8X  dA   V^,
          ^,          p
V^,
          V
,
          p\        P                  ! W«W«34      V n        ^ pMV^,
          ^,          p\        P
                  ! WW4V^VR4      p\        P                  ! V4      pR\        P                  R\        P                  R\        P                  /V,          ! RR7      pV P                  W}4       V P                  WŽ4       V P                  WŸ4       R# )r   FÚreluÚsiluÚnoneT)ÚinplaceN)ÚsuperÚ__init__r   Ú	ZeroPad2dÚpadÚConv2dÚBatchNorm2dÚReLUÚSiLUÚIdentityÚ__setattr__)Úselfr	   r   r   r   r   r   r   r   r   Úp1Úp2ÚpaddingÚconvÚnormÚ
activationÚ	__class__s   &&&&&&&&&&      €r   r"   ÚConvNormAct.__init__,   sÞ   ø€ ô 	‰ÑÔØ˜�?˜aÔð
  •/ aÕ'ˆBØ˜q• 2Õ%ˆBÜ—|’| R¨RÐ$4Ó5ˆDŒHØ‰Gà" Q•¨1Õ,ˆGÜ�yŠy˜°KÈÐRSÐU[Ð]bÓcˆÜ�~Š~˜lÓ+ˆØœbŸg™g v¬r¯w©w¸ÄÇÁÐLÈSÖQÐZ^Ô_ˆ
à×Ñ˜Ô+Ø×Ñ˜Ô+Ø×Ñ˜Ö0r   )r$   )é   r   r4   r/   r0   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   Ú__static_attributes__Ú__classcell__©r2   s   @r   r   r      s   ø† ñ÷$1÷ 1ð 1r   r   c                  óB   a € ] tR t^OtRtRR V 3R llltR R ltRtV ;t# )ÚMLPa]  Implement a Multi-Layer Perceptron (MLP) for feature projection.

Args:
    input_dim: The number of input features.
    hidden_dim: The number of features in hidden layers.
    output_dim: The number of output features.
    num_layers: The total number of layers.
    sigmoid_output: Whether to apply a sigmoid to the final output. Default: False.
c               ó0   € V ^8„  d   QhRRRRRRRRRRRR	/# )
r   Ú	input_dimr
   Ú
hidden_dimÚ
output_dimÚ
num_layersÚsigmoid_outputÚboolr   r   r   )r   s   "r   r   ÚMLP.__annotate__Z   s<   € ÷ -ñ -Øð-Ø*-ð-Ø;>ð-ØLOð-Øaeð-à	ñ-r   c                	óÄ   <€ \         SV `  4        W@n        V.V^,
          ,          p\        P                  ! R \        V.VO. VOVN4       4       4      V n        WPn        R# )r4   c              3  óR   "  € T F  w  r\         P                  ! W4      x € K  	  R # 5i©N)r   ÚLinear)Ú.0ÚnÚks   &  r   Ú	<genexpr>ÚMLP.__init__.<locals>.<genexpr>`   s   é € Ð#gÑ@f¹¸¤B§I¢I¨a§O OÓ@fùs   ‚%'N)r!   r"   rC   r   Ú
ModuleListÚzipÚlayersrD   )r+   r@   rA   rB   rC   rD   Úhr2   s   &&&&&& €r   r"   ÚMLP.__init__Z   s\   ø€ ô 	‰ÑÔØ$ŒØˆL˜J¨�NÕ+ˆÜ—m’mÑ#gÄÀYÀOÐQRÀOÐUeÐWXÐUeÐZdÐUeÔ@fÓ#gÓgˆŒØ,Ör   c               ó    € V ^8„  d   QhRRRR/# ©r   Úxútorch.Tensorr   r   )r   s   "r   r   rF   c   s   € ÷ ñ ˜ð ¨,ñ r   c                ó  € \        V P                  4       F@  w  r#W P                  ^,
          8  d   \        P                  ! V! V4      4      MV! V4      pKB  	  V P
                  '       d   \        P                  ! V4      pV# )a9  Apply the configured MLP to the last tensor dimension.

Args:
    x: Input tensor whose last dimension equals ``input_dim``.

Returns:
    Tensor with the same leading dimensions as ``x`` and final
    dimension ``output_dim``. If ``sigmoid_output`` is enabled, the
    final values are passed through a sigmoid.
)Ú	enumeraterR   rC   ÚFr   rD   Úsigmoid)r+   rW   ÚiÚlayers   &&  r   ÚforwardÚMLP.forwardc   s]   € ô " $§+¡+Ö.‰HˆAØ$%¯©¸!Õ(;Ô$;”—’‘u˜Q“xÔ ÁÀqÃŠAñ /à××ÐÜ—	’	˜!“ˆAØˆr   )rR   rC   rD   )F©	r5   r6   r7   r8   r9   r"   r_   r:   r;   r<   s   @r   r>   r>   O   s   ø† ñ÷-ò -÷ó r   r>   c                  óB   a € ] tR t^wtRtRR V 3R llltR R ltRtV ;t# )ÚDropPathzYDrop paths (Stochastic Depth) per sample  (when applied in main path of residual blocks).c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ú	drop_probÚfloatÚscale_by_keeprE   r   r   r   )r   s   "r   r   ÚDropPath.__annotate__z   s!   € ÷ +ñ + %ð +¸dð +Èdñ +r   c                	ó<   <€ \         SV `  4        Wn        W n        R # rI   )r!   r"   re   rg   )r+   re   rg   r2   s   &&&€r   r"   ÚDropPath.__init__z   s   ø€ Ü‰ÑÔØ"ŒØ*Ör   c               ó    € V ^8„  d   QhRRRR/# rV   r   )r   s   "r   r   rh      s   € ÷ !ñ !˜ð !¨,ñ !r   c                ó|  € V P                   R8X  g   V P                  '       g   V# ^V P                   ,
          pVP                  ^ ,          3RVP                  ^,
          ,          ,           pVP	                  V4      P                  V4      pVR8”  d$   V P                  '       d   VP                  V4       W,          # )au  Apply stochastic depth to a residual branch.

Args:
    x: Residual-branch tensor with arbitrary shape. The first dimension
        is treated as the batch dimension.

Returns:
    Tensor with the same shape as ``x``. During training, complete
    samples may be dropped and optionally scaled by the keep
    probability; during evaluation the input is returned unchanged.
ç        )r4   )re   ÚtrainingÚshapeÚndimÚ	new_emptyÚ
bernoulli_rg   Údiv_)r+   rW   Ú	keep_probro   Úrandom_tensors   &&   r   r_   ÚDropPath.forward   sŽ   € ð �>‰>˜SÔ ¨¯¯¨ØˆHØ˜Ÿ™Õ&ˆ	Ø—‘˜•� ¨¯©°­
Õ 3Õ3ˆØŸ™ EÓ*×5Ñ5°iÓ@ˆØ�sŒ?˜t×1×1Ð1Ø×Ñ˜yÔ)ØÕ Ð r   )re   rg   )rm   Tra   r<   s   @r   rc   rc   w   s   ø† Ùc÷+ò +÷
!ó !r   rc   c                  óN   a € ] tR t^—tRtR	R V 3R llltR R ltR R ltRtV ;t	# )
ÚLayerNorm2daä  Apply Layer Normalization over a 4D input tensor (NCHW).

A float16 or bfloat16 input is normalised in float32, and the result is cast to the promoted dtype of the input and
the weight (a float16 input with float32 weights gives float32). In float16, the squared deviations overflow once a
value is more than 255.9 from its channel mean, and the variance becomes ``inf``, which leaves only the bias.
MobileSAM's neck reaches about 560, and a float16 variance there gives empty masks.
c               ó$   € V ^8„  d   QhRRRRRR/# )r   Únum_channelsr
   Úepsrf   r   r   r   )r   s   "r   r   ÚLayerNorm2d.__annotate__    s!   € ÷ ñ  Sð ¨uð Àñ r   c                	óì   <€ \         SV `  4        \        P                  ! \        P
                  ! V4      4      V n        \        P                  ! \        P                  ! V4      4      V n        W n	        R # rI   )
r!   r"   r   Ú	ParameterÚtorchÚonesÚweightÚzerosÚbiasr{   )r+   rz   r{   r2   s   &&&€r   r"   ÚLayerNorm2d.__init__    sE   ø€ Ü‰ÑÔÜ—l’l¤5§:¢:¨lÓ#;Ó<ˆŒÜ—L’L¤§¢¨\Ó!:Ó;ˆŒ	ØŽr   c               ó    € V ^8„  d   QhRRRR/# rV   r   )r   s   "r   r   r|   ¦   s   € ÷ :ñ :˜ð :¨,ñ :r   c                óÖ  € VP                   \        P                  \        P                  39   d–   \        P                  ! VP                   V P
                  P                   4      pV P                  VP                  4       V P
                  P                  4       V P                  P                  4       4      P                  V4      # V P                  WP
                  V P                  4      # )aq  Apply channel-wise layer normalization to an NCHW tensor.

Args:
    x: Tensor with shape ``(B, C, H, W)``, where :math:`B` is batch
        size, :math:`C` is channel count, :math:`H` is height, and
        :math:`W` is width.

Returns:
    Tensor with the same shape as ``x`` after normalizing across the
    channel dimension and applying learned affine parameters.
)
Údtyper   Úfloat16Úbfloat16Úpromote_typesr�   Ú
_normalizerf   rƒ   Úto)r+   rW   Ú	out_dtypes   && r   r_   ÚLayerNorm2d.forward¦   s“   € ð �7‰7”u—}‘}¤e§n¡nÐ5Ô5Ü×+Ò+¨A¯G©G°T·[±[×5FÑ5FÓGˆIØ—?‘? 1§7¡7£9¨d¯k©k×.?Ñ.?Ó.AÀ4Ç9Á9Ç?Á?ÓCTÓU×XÑXÐYbÓcÐcØ�‰˜q§+¡+¨t¯y©yÓ9Ð9r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rW   rX   r�   rƒ   r   r   )r   s   "r   r   r|   ·   s)   € ÷ ?ñ ?˜Lð ?°,ð ?Àlð ?ÐWcñ ?r   c                	ó  € VP                  ^RR7      pW,
          P                  ^4      P                  ^RR7      pW,
          WPP                  ,           P                  4       ,          pVR,          V,          VR,          ,           # )r4   T)Úkeepdim)ºNNNNN)ÚmeanÚpowr{   Úsqrt)r+   rW   r�   rƒ   ÚuÚss   &&&&  r   r‹   ÚLayerNorm2d._normalize·   sh   € Ø�F‰F�1˜dˆFÓ#ˆØ�U�K‰K˜‹N×Ñ ¨4ÐÓ0ˆØ�U�qŸ8™8•|×)Ñ)Ó+Õ+ˆØ�mÕ$ qÕ(¨4°Õ+>Õ>Ð>r   )rƒ   r{   r�   )g�íµ ÷Æ°>)
r5   r6   r7   r8   r9   r"   r_   r‹   r:   r;   r<   s   @r   rx   rx   —   s!   ø† ñ÷ò õ:÷"?ó ?r   rx   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rW   rX   Úwindow_sizer
   r   z$tuple[torch.Tensor, tuple[int, int]]r   )r   s   "r   r   r   ¾   s"   € ÷ ñ ˜ð °3ð Ð;_ñ r   c           	     ó   € V P                   w  r#rEWV,          ,
          V,          pWV,          ,
          V,          pV^ 8”  g   V^ 8”  d   \        P                  ! V ^ ^ ^ V^ V34      p W6,           WG,           r˜V P                  W(V,          WV,          W4      p V P	                  ^ ^^^^^4      P                  4       P                  ^ ^4      p
W¨V	33# )a'  Partition into non-overlapping windows with padding if needed.

Args:
    x: input tokens with [B, H, W, C].
    window_size: window size.

Returns:
    windows: windows after partition with [B * num_windows, window_size, window_size, C].
    (Hp, Wp): padded height and width before partition

)ro   r[   r$   ÚviewÚpermuteÚ
contiguousÚflatten)rW   rš   ÚBÚHÚWÚCÚpad_hÚpad_wÚHpÚWpÚwindowss   &&         r   Úwindow_partitionr©   ¾   s¿   € ð —‘�J€Aˆ!à˜{�?Õ*¨kÕ9€EØ˜{�?Õ*¨kÕ9€EØˆq„y�E˜A”IÜ�EŠE�!�a˜˜A˜u a¨Ð/Ó0ˆØ�Y˜�	ˆà	�‰ˆq˜Õ# [¸Õ2CÀ[ÓT€AØ�i‰i˜˜1˜a  A qÓ)×4Ñ4Ó6×>Ñ>¸qÀ!ÓD€GØ˜�HÐÐr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r¨   rX   rš   r
   Úpad_hwztuple[int, int]Úhwr   r   )r   s   "r   r   r   ×   s4   € ÷ ñ ØðØ(+ðØ5DðØJYðàñr   c                ó˜  € Vw  rEVw  rgV P                   ^ ,          WE,          V,          V,          ,          pV P                   R,          p	V P                  W„V,          WQ,          WV	4      p
V
P                  ^ ^^^^^4      P                  4       P                  W„WY4      p
WF8”  g   WW8”  d    V
RRV1RV1R3,          P                  4       p
V
# )aY  Window unpartition into original sequences and removing padding.

Args:
    windows: input tokens with [B * num_windows, window_size, window_size, C].
    window_size: window size.
    pad_hw: padded height and width (Hp, Wp).
    hw: original height and width (H, W) before padding.

Returns:
    x: unpartitioned sequences with [B, H, W, C].

r’   Néÿÿÿÿ)ro   rœ   r�   rž   )r¨   rš   r«   r¬   r¦   r§   r¡   r¢   r    r£   rW   s   &&&&       r   Úwindow_unpartitionr¯   ×   sº   € ð �F€BØ�D€AØ�‰�aÕ˜R�W¨Õ3°{ÕBÕC€AØ�‰�bÕ€AØ�‰�Q˜kÕ)¨2Õ+<¸kÐXYÓZ€AØ	�	‰	�!�Q˜˜1˜a Ó#×.Ñ.Ó0×5Ñ5°a¸RÓC€Aà	„v�”Øˆa��!��R�a�R˜ˆl�O×&Ñ&Ó(ˆØ€Hr   )Ú
__future__r   r   Útorch.nn.functionalr   Ú
functionalr[   Ú
Sequentialr   ÚModuler>   rc   rx   r©   r¯   r   r   r   Ú<module>rµ      sd   ðõ$ #ã ß Ð Ý ô11�"—-‘-ô 11ôl#ˆ"�)‰)ô #ôP!ˆr�y‰yô !ô@$?�"—)‘)ô $?õN÷2r   