+
    ˜°³jÔ   ã                   óZ  € ^ RI Ht ^ RIt^ RIHt ^ RIHtHt ^ RIH	t	H
t
Ht ^RIHt ^RIHt ^RIHt . ROt ! R R]4      t ! R R]4      t ! R R]]4      t ! R R	]4      t ! R R
]]4      t ! R R]4      t ! R R]]4      t ! R R]4      t ! R R]]4      t ! R R]4      tR# )é    )ÚAnyN©ÚTensor)Ú
functionalÚinit)Ú	ParameterÚUninitializedBufferÚUninitializedParameter)ÚSyncBatchNorm)ÚLazyModuleMixin)ÚModuleÚBatchNorm1dÚLazyBatchNorm1dÚBatchNorm2dÚLazyBatchNorm2dÚBatchNorm3dÚLazyBatchNorm3dr   c                   ó®   a a€ ] tR t^t oRt^t. ROtRRR/V3R lV 3R lllltV3R lR ltV3R lR	 lt	R
 t
R tV3R lV 3R lltV3R ltRtVtV ;t# )Ú	_NormBasez,Common base of _InstanceNorm and _BatchNorm.TÚbiasc                óP   <€ V ^8„  d   QhRS[ RS[RS[R,          RS[RS[RS[RR/# ©	é   Únum_featuresÚepsÚmomentumNÚaffineÚtrack_running_statsr   Úreturn©ÚintÚfloatÚbool)ÚformatÚ__classdict__s   "€Ú[/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/nn/modules/batchnorm.pyÚ__annotate__Ú_NormBase.__annotate__&   sU   ø€ ÷ 3 ñ 3 áð3 ñ ð3 ñ ˜$•,ð	3 ñ
 ð3 ñ "ð3 ñ ð3 ð 
ñ3 ó    c               óÌ  <€ R VRV/p	\         SV `  4        Wn        W n        W0n        W@n        WPn        V P
                  '       dg   \        \        P                  ! V3/ V	B 4      V n
        V'       d'   \        \        P                  ! V3/ V	B 4      V n        M7V P                  RR4       M$V P                  RR4       V P                  RR4       V P                  '       d·   V P                  R\        P                  ! V3/ V	B 4       V P                  R\        P                  ! V3/ V	B 4       V  V  T P                  R\        P                   ! RR\        P"                  /V	P%                  4        U
Uu/ uF  w  r«V
R8w  g   K  W«bK  	  upp
B 4       V  M6V P                  RR4       V P                  RR4       V P                  RR4       V P'                  4        R# u upp
i )	ÚdeviceÚdtyper   NÚweightÚrunning_meanÚrunning_varÚnum_batches_tracked©r   )ÚsuperÚ__init__r   r   r   r   r   r   ÚtorchÚemptyr-   r   Úregister_parameterÚregister_bufferÚzerosÚonesÚtensorÚlongÚitemsÚreset_parameters)Úselfr   r   r   r   r   r+   r,   r   Úfactory_kwargsÚkÚvÚ	__class__s   &&&&&&&&$   €r&   r3   Ú_NormBase.__init__&   s¢  ø€ ð # F¨G°UÐ;ˆÜ‰ÑÔØ(ÔØŒØ ŒØŒØ#6Ô Ø�;�;ˆ;Ü#¤E§K¢K°Ñ$OÀÑ$OÓPˆDŒKßÜ%¤e§k¢k°,Ñ&QÀ.Ñ&QÓR�•	à×'Ñ'¨°Õ5à×#Ñ# H¨dÔ3Ø×#Ñ# F¨DÔ1Ø×#×#Ð#Ø× Ñ Ø¤§¢¨LÑ K¸NÑ Kôð × Ñ ØœuŸzšz¨,ÑI¸.ÑIôñ ÙØ× Ñ Ø%Ü—’ñ äŸ*™*ðð )7×(<Ñ(<Ô(>ÔOÑ(>¡ À!ÀwÁ,”t�q’tÑ(>ÒOñ	ôò à× Ñ  °Ô6Ø× Ñ  °Ô5Ø× Ñ Ð!6¸Ô=Ø×ÑÖùó Ps   Å5G ÆG c                ó   <€ V ^8„  d   QhRR/# ©r   r   N© )r$   r%   s   "€r&   r'   r(   [   s   ø€ ÷ -ñ - Tñ -r)   c                óÌ   € V P                   '       dR   V P                  P                  4        V P                  P	                  ^4       V P
                  P                  4        R# R# )é   N)r   r.   Úzero_r/   Úfill_r0   ©r>   s   &r&   Úreset_running_statsÚ_NormBase.reset_running_stats[   sM   € Ø×#×#Ð#ð ×Ñ×#Ñ#Ô%Ø×Ñ×"Ñ" 1Ô%Ø×$Ñ$×*Ñ*Ö,ñ $r)   c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   r(   c   s   ø€ ÷ 'ñ ' $ñ 'r)   c                óî   € V P                  4        V P                  '       dS   \        P                  ! V P                  4       V P
                  e#   \        P                  ! V P
                  4       R # R # R # ©N)rL   r   r   Úones_r-   r   Úzeros_rK   s   &r&   r=   Ú_NormBase.reset_parametersc   sK   € Ø× Ñ Ô"Ø�;�;ˆ;Ü�JŠJ�t—{‘{Ô#Ø�y‰yÒ$Ü—’˜DŸI™IÖ&ñ %ñ r)   c                ó   € \         hrP   )ÚNotImplementedError©r>   Úinputs   &&r&   Ú_check_input_dimÚ_NormBase._check_input_dimj   s   € Ü!Ð!r)   c                óZ   € R P                   ! R/ V P                  BRV P                  RJ/B # )z{{num_features}, eps={eps}, momentum={momentum}, affine={affine}, bias={use_bias}, track_running_stats={track_running_stats}Úuse_biasNrF   )r$   Ú__dict__r   rK   s   &r&   Ú
extra_reprÚ_NormBase.extra_reprm   s:   € ðIßIOÉðPñ à—-‘-ñà*.¯)©)¸4Ð*?òð	
r)   c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   r(   u   s   ø€ ÷  
ñ  
ð 
ñ 
r)   c           	     ó�  <€ VP                  R R4      pVe   V^8  d“   V P                  '       d�   VR,           p	W‘9  dr   V P                  e<   V P                  P                  \        P                  ! R4      8w  d   V P                  M%\        P
                  ! ^ \        P                  R7      W&   \        S
V `!  VVVVVVV4       R# )ÚversionNr0   Úmeta)r,   )	Úgetr   r0   r+   r4   r:   r;   r2   Ú_load_from_state_dict)r>   Ú
state_dictÚprefixÚlocal_metadataÚstrictÚmissing_keysÚunexpected_keysÚ
error_msgsra   Únum_batches_tracked_keyrB   s   &&&&&&&&  €r&   rd   Ú_NormBase._load_from_state_dictu   s·   ø€ ð !×$Ñ$ Y°Ó5ˆàŠO˜w¨œ{°×0H×0HÐ0Hð '-Ð/DÕ&DÐ#Ø&Ô8ð ×/Ñ/Ò;Ø×0Ñ0×7Ñ7¼5¿<º<ÈÓ;OÔOð ×,Ò,ô Ÿš a¬u¯z©zÔ:ð	 Ñ3ô 	‰Ñ%ØØØØØØØö	
r)   c                ód   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[R,          ;R&   S[;R&   S[;R&   # )r   r   r   Nr   r   r   r    )r$   r%   s   "€r&   r'   r(      sH   ø‡ ‚ ñ
 Ññ ñ 
�Jñ ñ �d�lÑñ ñ �Lñ ñ Ñò r)   )r   r   r   r   r   r   r-   )r   r   r   r   r   ©çñhãˆµøä>çš™™™™™¹?TTNN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_versionÚ__constants__r3   rL   r=   rX   r]   rd   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__©rB   r%   s   @@r&   r   r      sW   ù‡ € Ù6à€HÚX€Mñ3 ð ÷3 ö 3 ÷j-ð -÷'ð 'ò"ò
÷ 
ó  
÷y … r)   r   c                   ó\   a a€ ] tR t^˜t oRRR/V3R lV 3R lllltV3R lR ltRtVtV ;t# )	Ú
_BatchNormTr   c                óP   <€ V ^8„  d   QhRS[ RS[RS[R,          RS[RS[RS[RR/# r   r    )r$   r%   s   "€r&   r'   Ú_BatchNorm.__annotate__™   sU   ø€ ÷ 
ñ 
áð
ñ ð
ñ ˜$•,ð	
ñ
 ð
ñ "ð
ñ ð
ð 
ñ
r)   c               óF   <€ R VRV/p	\         S
V `  ! VVVVV3/ V	BRV/B  R# ©r+   r,   r   N)r2   r3   )r>   r   r   r   r   r   r+   r,   r   r?   rB   s   &&&&&&&&$ €r&   r3   Ú_BatchNorm.__init__™   sC   ø€ ð # F¨G°UÐ;ˆÜ‰ÒØØØØØñ	
ð ñ	
ð õ	
r)   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# ©r   rW   r   r   )r$   r%   s   "€r&   r'   r�   °   s   ø€ ÷ 0
ñ 0
™Vð 0
©ñ 0
r)   c           
     ó  € V P                  V4       V P                  f   RpMV P                  pV P                  '       ds   V P                  '       da   V P                  eS   V P                  P                  ^4       V P                  f   R\        V P                  4      ,          pMV P                  p V P                  '       d   RpM$V P                  R J ;'       d    V P                  R J p \        P                  ! TV P                  '       d   V P                  '       d   V P                  MR V P                  '       d   V P                  '       d   V P                  MR V P                  V P                  VVV P                  4      # )Nç        ç      ð?T)rX   r   Útrainingr   r0   Úadd_r"   r.   r/   ÚFÚ
batch_normr-   r   r   )r>   rW   Úexponential_average_factorÚbn_trainings   &&  r&   ÚforwardÚ_BatchNorm.forward°   s;  € Ø×Ñ˜eÔ$ð
 �=‰=Ò Ø),Ñ&à)-¯©Ð&à�=�=ˆ=˜T×5×5Ð5à×'Ñ'Ò3Ø×(Ñ(×-Ñ-¨aÔ0Ø—=‘=Ò(Ø14´u¸T×=UÑ=UÓ7VÕ1VÑ.à15·±Ð.ð	ð �=�=ˆ=Ø‰Kà×,Ñ,°Ð4×TÐT¸4×;KÑ;KÈtÐ;SˆKð	ô
 �|Š|Øð —}—}�}¨×(@×(@Ð(@ð ×!Ò!àà$(§M§M M°T×5M×5MÐ5MˆD×ÒÐSWØ�K‰KØ�I‰IØØ&Ø�H‰Hó
ð 	
r)   rF   ro   )	rr   rs   rt   ru   r3   r�   rz   r{   r|   r}   s   @@r&   r   r   ˜   s(   ù‡ € ñ
ð ÷
ö 
÷.0
÷ 0
ð 0
r)   r   c                   ó€   a a€ ] tR t^ãt oRRR/V3R lV 3R lllltV3R lV 3R lltV3R lR ltV3R	 ltR
tVt	V ;t
# )Ú_LazyNormBaseTr   c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   Ú_LazyNormBase.__annotate__ç   s   ø€ ÷ *ñ *ð 
ñ*r)   c          
     óò  <€ R VRV/p\         SV `  ! ^ VVRR3/ VBRR/B  W0n        W@n        V P                  '       d)   \	        R/ VB V n        V'       d   \	        R/ VB V n        V P                  '       dy   \        R/ VB V n        \        R/ VB V n	        \        P                  ! RR\        P                  /VP                  4        U	U
u/ uF  w  ršV	R8w  g   K  WšbK  	  up
p	B V n        R# R# u up
p	i )r+   r,   Fr   NrF   r1   )r2   r3   r   r   r
   r-   r   r	   r.   r/   r4   r:   r;   r<   r0   )r>   r   r   r   r   r+   r,   r   r?   r@   rA   rB   s   &&&&&&&$   €r&   r3   Ú_LazyNormBase.__init__ç   s   ø€ ð # F¨G°UÐ;ˆä‰Òð ØØØØñ
	
ð ñ
	
ð ó
	
ð ŒØ#6Ô Ø�;�;ˆ;ä0ÑB°>ÑBˆDŒKßä2ÑD°^ÑD�”	Ø×#×#Ð#ä 3Ñ E°nÑ EˆDÔä2ÑD°^ÑDˆDÔÜ',§|¢|ñ (ä—j‘jð(ð %3×$8Ñ$8Ô$:ÔKÑ$:™D˜A¸aÀ7¹l”4�1’4Ñ$:ÒKñ	(ˆDÖ$ñ $ùó Ls   ÃC3ÃC3c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   r•     s   ø€ ÷ 'ñ ' $ñ 'r)   c                óz   <€ V P                  4       '       g$   V P                  ^ 8w  d   \        SV `  4        R# R# R# )r   N)Úhas_uninitialized_paramsr   r2   r=   )r>   rB   s   &€r&   r=   Ú_LazyNormBase.reset_parameters  s3   ø€ à×,Ñ,×.Ò.°4×3DÑ3DÈÔ3IÜ‰GÑ$Ö&ñ 4JÑ.r)   c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   r•     s   ø€ ÷ $ñ $¨dñ $r)   c                óÈ  € V P                  4       '       EdK   VP                  ^,          V n        V P                  '       d±   \	        V P
                  \        4      '       g   \        R4      hV P
                  P                  V P                  34       V P                  eR   \	        V P                  \        4      '       g   \        R4      hV P                  P                  V P                  34       V P                  '       dM   V P                  P                  V P                  34       V P                  P                  V P                  34       V P                  4        R# R# )rH   z-self.weight must be an UninitializedParameterNz+self.bias must be an UninitializedParameter)rš   Úshaper   r   Ú
isinstancer-   r
   ÚAssertionErrorÚmaterializer   r   r.   r/   r=   rV   s   &&r&   Úinitialize_parametersÚ#_LazyNormBase.initialize_parameters  s  € à×(Ñ(×*Ó*Ø %§¡¨A¥ˆDÔØ�{�{ˆ{Ü! $§+¡+Ô/E×FÒFÜ(ØGóð ð —‘×'Ñ'¨×):Ñ):Ð(<Ô=Ø—9‘9Ò(Ü% d§i¡iÔ1G×HÒHÜ,ØIóð ð —I‘I×)Ñ)¨4×+<Ñ+<Ð*>Ô?Ø×'×'Ð'Ø×!Ñ!×-Ñ-Ø×&Ñ&Ð(ôð × Ñ ×,Ñ,Ø×&Ñ&Ð(ôð ×!Ñ!Ö#ñ+ +r)   c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   # )r   r-   r   )r
   )r$   r%   s   "€r&   r'   r•   ã   s   ø‡ ‚ Ù"Ñ"ñ á
 Ñ ò r)   )r   r   r0   r   r.   r/   r   r-   ro   )rr   rs   rt   ru   r3   r=   r¢   ry   rz   r{   r|   r}   s   @@r&   r“   r“   ã   s6   ù‡ € ñ*ð ÷*ö *÷X'ó '÷
$ð $÷k … r)   r“   c                   ó6   a € ] tR tRt o RtV 3R lR ltRtV tR# )r   i2  a™  Applies Batch Normalization over a 2D or 3D input.

Method described in the paper
`Batch Normalization: Accelerating Deep Network Training by Reducing
Internal Covariate Shift <https://arxiv.org/abs/1502.03167>`__ .

.. math::

    y = \frac{x - \mathrm{E}[x]}{\sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta

The mean and standard-deviation are calculated per-dimension over
the mini-batches and :math:`\gamma` and :math:`\beta` are learnable parameter vectors
of size `C` (where `C` is the number of features or channels of the input). By default, the
elements of :math:`\gamma` are set to 1 and the elements of :math:`\beta` are set to 0.
At train time in the forward pass, the variance is calculated via the biased estimator,
equivalent to ``torch.var(input, correction=0)``. However, the value stored in the
moving average of the variance is calculated via the unbiased estimator, equivalent to
``torch.var(input, correction=1)``.

Also by default, during training this layer keeps running estimates of its
computed mean and variance, which are then used for normalization during
evaluation. The running estimates are kept with a default :attr:`momentum`
of 0.1.

If :attr:`track_running_stats` is set to ``False``, this layer then does not
keep running estimates, and batch statistics are instead used during
evaluation time as well.

.. note::
    This :attr:`momentum` argument is different from one used in optimizer
    classes and the conventional notion of momentum. Mathematically, the
    update rule for running statistics here is
    :math:`\hat{x}_\text{new} = (1 - \text{momentum}) \times \hat{x} + \text{momentum} \times x_t`,
    where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
    new observed value.

Because the Batch Normalization is done over the `C` dimension, computing statistics
on `(N, L)` slices, it's common terminology to call this Temporal Batch Normalization.

Args:
    num_features: number of features or channels :math:`C` of the input
    eps: a value added to the denominator for numerical stability.
        Default: 1e-5
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``

Shape:
    - Input: :math:`(N, C)` or :math:`(N, C, L)`, where :math:`N` is the batch size,
      :math:`C` is the number of features or channels, and :math:`L` is the sequence length
    - Output: :math:`(N, C)` or :math:`(N, C, L)` (same shape as input)

Examples::

    >>> # With Learnable Parameters
    >>> m = nn.BatchNorm1d(100)
    >>> # Without Learnable Parameters
    >>> m = nn.BatchNorm1d(100, affine=False)
    >>> input = torch.randn(20, 100)
    >>> output = m(input)
c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   ÚBatchNorm1d.__annotate__{  ó   ø€ ÷ Tñ T¨ñ Tr)   c                ó˜   € VP                  4       ^8w  d5   VP                  4       ^8w  d   \        RVP                  4        R24      hR# R# ©r   zexpected 2D or 3D input (got úD input)N©ÚdimÚ
ValueErrorrV   s   &&r&   rX   ÚBatchNorm1d._check_input_dim{  ó@   € Ø�9‰9‹;˜!Ô §	¡	£¨qÔ 0ÜÐ<¸U¿Y¹Y»[¸MÈÐRÓSÐSñ !1Ñr)   rF   N©rr   rs   rt   ru   rv   rX   rz   r{   ©r%   s   @r&   r   r   2  s   ø‡ € ñF÷PTö Tr)   c                   ó:   a € ] tR tRt o Rt]tV 3R lR ltRtV t	R# )r   i€  a�  A :class:`torch.nn.BatchNorm1d` module with lazy initialization.

Lazy initialization based on the ``num_features`` argument of the :class:`BatchNorm1d` that is inferred
from the ``input.size(1)``.
The attributes that will be lazily initialized are `weight`, `bias`,
`running_mean` and `running_var`.

Check the :class:`torch.nn.modules.lazy.LazyModuleMixin` for further documentation
on lazy modules and their limitations.

Args:
    eps: a value added to the denominator for numerical stability.
        Default: 1e-5
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``
c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   ÚLazyBatchNorm1d.__annotate__Ÿ  r¨   r)   c                ó˜   € VP                  4       ^8w  d5   VP                  4       ^8w  d   \        RVP                  4        R24      hR# R# rª   r¬   rV   s   &&r&   rX   Ú LazyBatchNorm1d._check_input_dimŸ  r°   r)   rF   N)
rr   rs   rt   ru   rv   r   Úcls_to_becomerX   rz   r{   r²   s   @r&   r   r   €  s   ø‡ € ñð8  €M÷Tö Tr)   c                   ó6   a € ] tR tRt o RtV 3R lR ltRtV tR# )r   i¤  aF  Applies Batch Normalization over a 4D input.

4D is a mini-batch of 2D inputs
with additional channel dimension. Method described in the paper
`Batch Normalization: Accelerating Deep Network Training by Reducing
Internal Covariate Shift <https://arxiv.org/abs/1502.03167>`__ .

.. math::

    y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta

The mean and standard-deviation are calculated per-dimension over
the mini-batches and :math:`\gamma` and :math:`\beta` are learnable parameter vectors
of size `C` (where `C` is the input size). By default, the elements of :math:`\gamma` are set
to 1 and the elements of :math:`\beta` are set to 0. At train time in the forward pass, the
standard-deviation is calculated via the biased estimator, equivalent to
``torch.var(input, correction=0)``. However, the value stored in the moving average of the
standard-deviation is calculated via the unbiased estimator, equivalent to
``torch.var(input, correction=1)``.

Also by default, during training this layer keeps running estimates of its
computed mean and variance, which are then used for normalization during
evaluation. The running estimates are kept with a default :attr:`momentum`
of 0.1.

If :attr:`track_running_stats` is set to ``False``, this layer then does not
keep running estimates, and batch statistics are instead used during
evaluation time as well.

.. note::
    This :attr:`momentum` argument is different from one used in optimizer
    classes and the conventional notion of momentum. Mathematically, the
    update rule for running statistics here is
    :math:`\hat{x}_\text{new} = (1 - \text{momentum}) \times \hat{x} + \text{momentum} \times x_t`,
    where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
    new observed value.

Because the Batch Normalization is done over the `C` dimension, computing statistics
on `(N, H, W)` slices, it's common terminology to call this Spatial Batch Normalization.

Args:
    num_features: :math:`C` from an expected input of size
        :math:`(N, C, H, W)`
    eps: a value added to the denominator for numerical stability.
        Default: 1e-5
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``

Shape:
    - Input: :math:`(N, C, H, W)`
    - Output: :math:`(N, C, H, W)` (same shape as input)

Examples::

    >>> # With Learnable Parameters
    >>> m = nn.BatchNorm2d(100)
    >>> # Without Learnable Parameters
    >>> m = nn.BatchNorm2d(100, affine=False)
    >>> input = torch.randn(20, 100, 35, 45)
    >>> output = m(input)
c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   ÚBatchNorm2d.__annotate__î  ó   ø€ ÷ Nñ N¨ñ Nr)   c                ój   € VP                  4       ^8w  d   \        RVP                  4        R24      hR# ©é   zexpected 4D input (got r«   Nr¬   rV   s   &&r&   rX   ÚBatchNorm2d._check_input_dimî  ó0   € Ø�9‰9‹;˜!ÔÜÐ6°u·y±y³{°mÀ8ÐLÓMÐMñ r)   rF   Nr±   r²   s   @r&   r   r   ¤  ó   ø‡ € ñG÷RNö Nr)   c                   ó:   a € ] tR tRt o Rt]tV 3R lR ltRtV t	R# )r   ió  a“  A :class:`torch.nn.BatchNorm2d` module with lazy initialization.

Lazy initialization is done for the ``num_features`` argument of the :class:`BatchNorm2d` that is inferred
from the ``input.size(1)``.
The attributes that will be lazily initialized are `weight`, `bias`,
`running_mean` and `running_var`.

Check the :class:`torch.nn.modules.lazy.LazyModuleMixin` for further documentation
on lazy modules and their limitations.

Args:
    eps: a value added to the denominator for numerical stability.
        Default: 1e-5
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``
c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   ÚLazyBatchNorm2d.__annotate__  r¼   r)   c                ój   € VP                  4       ^8w  d   \        RVP                  4        R24      hR# r¾   r¬   rV   s   &&r&   rX   Ú LazyBatchNorm2d._check_input_dim  rÁ   r)   rF   N)
rr   rs   rt   ru   rv   r   r¸   rX   rz   r{   r²   s   @r&   r   r   ó  ó   ø‡ € ñð8  €M÷Nö Nr)   c                   ó6   a € ] tR tRt o RtV 3R lR ltRtV tR# )r   i  a{  Applies Batch Normalization over a 5D input.

5D is a mini-batch of 3D inputs with additional channel dimension as described in the paper
`Batch Normalization: Accelerating Deep Network Training by Reducing
Internal Covariate Shift <https://arxiv.org/abs/1502.03167>`__ .

.. math::

    y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta

The mean and standard-deviation are calculated per-dimension over
the mini-batches and :math:`\gamma` and :math:`\beta` are learnable parameter vectors
of size `C` (where `C` is the input size). By default, the elements of :math:`\gamma` are set
to 1 and the elements of :math:`\beta` are set to 0. At train time in the forward pass, the
standard-deviation is calculated via the biased estimator, equivalent to
``torch.var(input, correction=0)``. However, the value stored in the moving average of the
standard-deviation is calculated via the unbiased estimator, equivalent to
``torch.var(input, correction=1)``.

Also by default, during training this layer keeps running estimates of its
computed mean and variance, which are then used for normalization during
evaluation. The running estimates are kept with a default :attr:`momentum`
of 0.1.

If :attr:`track_running_stats` is set to ``False``, this layer then does not
keep running estimates, and batch statistics are instead used during
evaluation time as well.

.. note::
    This :attr:`momentum` argument is different from one used in optimizer
    classes and the conventional notion of momentum. Mathematically, the
    update rule for running statistics here is
    :math:`\hat{x}_\text{new} = (1 - \text{momentum}) \times \hat{x} + \text{momentum} \times x_t`,
    where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
    new observed value.

Because the Batch Normalization is done over the `C` dimension, computing statistics
on `(N, D, H, W)` slices, it's common terminology to call this Volumetric Batch Normalization
or Spatio-temporal Batch Normalization.

Args:
    num_features: :math:`C` from an expected input of size
        :math:`(N, C, D, H, W)`
    eps: a value added to the denominator for numerical stability.
        Default: 1e-5
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``

Shape:
    - Input: :math:`(N, C, D, H, W)`
    - Output: :math:`(N, C, D, H, W)` (same shape as input)

Examples::

    >>> # With Learnable Parameters
    >>> m = nn.BatchNorm3d(100)
    >>> # Without Learnable Parameters
    >>> m = nn.BatchNorm3d(100, affine=False)
    >>> input = torch.randn(20, 100, 35, 45, 10)
    >>> output = m(input)
c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   ÚBatchNorm3d.__annotate__a  r¼   r)   c                ój   € VP                  4       ^8w  d   \        RVP                  4        R24      hR# ©é   zexpected 5D input (got r«   Nr¬   rV   s   &&r&   rX   ÚBatchNorm3d._check_input_dima  rÁ   r)   rF   Nr±   r²   s   @r&   r   r     rÂ   r)   c                   ó:   a € ] tR tRt o Rt]tV 3R lR ltRtV t	R# )r   if  a“  A :class:`torch.nn.BatchNorm3d` module with lazy initialization.

Lazy initialization is done for the ``num_features`` argument of the :class:`BatchNorm3d` that is inferred
from the ``input.size(1)``.
The attributes that will be lazily initialized are `weight`, `bias`,
`running_mean` and `running_var`.

Check the :class:`torch.nn.modules.lazy.LazyModuleMixin` for further documentation
on lazy modules and their limitations.

Args:
    eps: a value added to the denominator for numerical stability.
        Default: 1e-5
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``
c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   ÚLazyBatchNorm3d.__annotate__…  r¼   r)   c                ój   € VP                  4       ^8w  d   \        RVP                  4        R24      hR# rÍ   r¬   rV   s   &&r&   rX   Ú LazyBatchNorm3d._check_input_dim…  rÁ   r)   rF   N)
rr   rs   rt   ru   rv   r   r¸   rX   rz   r{   r²   s   @r&   r   r   f  rÈ   r)   c                   ó˜   a a€ ] tR tRt oRtRRR/V3R lV 3R lllltV3R lR ltV3R	 lR
 ltV3R lR lt]	RR l4       t
RtVtV ;t# )r   iŠ  aM  Applies Batch Normalization over a N-Dimensional input.

The N-D input is a mini-batch of [N-2]D inputs with additional channel dimension as described in the paper
`Batch Normalization: Accelerating Deep Network Training by Reducing
Internal Covariate Shift <https://arxiv.org/abs/1502.03167>`__ .

.. math::

    y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta

The mean and standard-deviation are calculated per-dimension over all
mini-batches of the same process groups. :math:`\gamma` and :math:`\beta`
are learnable parameter vectors of size `C` (where `C` is the input size).
By default, the elements of :math:`\gamma` are sampled from
:math:`\mathcal{U}(0, 1)` and the elements of :math:`\beta` are set to 0.
The standard-deviation is calculated via the biased estimator, equivalent to
`torch.var(input, correction=0)`.

Also by default, during training this layer keeps running estimates of its
computed mean and variance, which are then used for normalization during
evaluation. The running estimates are kept with a default :attr:`momentum`
of 0.1.

If :attr:`track_running_stats` is set to ``False``, this layer then does not
keep running estimates, and batch statistics are instead used during
evaluation time as well.

.. note::
    This :attr:`momentum` argument is different from one used in optimizer
    classes and the conventional notion of momentum. Mathematically, the
    update rule for running statistics here is
    :math:`\hat{x}_\text{new} = (1 - \text{momentum}) \times \hat{x} + \text{momentum} \times x_t`,
    where :math:`\hat{x}` is the estimated statistic and :math:`x_t` is the
    new observed value.

Because the Batch Normalization is done for each channel in the ``C`` dimension, computing
statistics on ``(N, +)`` slices, it's common terminology to call this Volumetric Batch
Normalization or Spatio-temporal Batch Normalization.

Currently :class:`SyncBatchNorm` only supports
:class:`~torch.nn.DistributedDataParallel` (DDP) with single GPU per process. Use
:meth:`torch.nn.SyncBatchNorm.convert_sync_batchnorm()` to convert
:attr:`BatchNorm*D` layer to :class:`SyncBatchNorm` before wrapping
Network with DDP.

Args:
    num_features: :math:`C` from an expected input of size
        :math:`(N, C, +)`
    eps: a value added to the denominator for numerical stability.
        Default: ``1e-5``
    momentum: the value used for the running_mean and running_var
        computation. Can be set to ``None`` for cumulative moving average
        (i.e. simple average). Default: 0.1
    affine: a boolean value that when set to ``True``, this module has
        learnable affine parameters. Default: ``True``
    track_running_stats: a boolean value that when set to ``True``, this
        module tracks the running mean and variance, and when set to ``False``,
        this module does not track such statistics, and initializes statistics
        buffers :attr:`running_mean` and :attr:`running_var` as ``None``.
        When these buffers are ``None``, this module always uses batch statistics.
        in both training and eval modes. Default: ``True``
    process_group: synchronization of stats happen within each process group
        individually. Default behavior is synchronization across the whole
        world
    bias: If set to ``False``, the layer will not learn an additive bias (only relevant if
        :attr:`affine` is ``True``). Default: ``True``

Shape:
    - Input: :math:`(N, C, +)`
    - Output: :math:`(N, C, +)` (same shape as input)

.. note::
    Synchronization of batchnorm statistics occurs only while training, i.e.
    synchronization is disabled when ``model.eval()`` is set or if
    ``self.training`` is otherwise ``False``.

Examples::

    >>> # xdoctest: +SKIP
    >>> # With Learnable Parameters
    >>> m = nn.SyncBatchNorm(100)
    >>> # creating process group (optional)
    >>> # ranks is a list of int identifying rank ids.
    >>> ranks = list(range(8))
    >>> r1, r2 = ranks[:4], ranks[4:]
    >>> # Note: every rank calls into new_group for every
    >>> # process group created, even if that rank is not
    >>> # part of the group.
    >>> process_groups = [torch.distributed.new_group(pids) for pids in [r1, r2]]
    >>> process_group = process_groups[0 if dist.get_rank() <= 3 else 1]
    >>> # Without Learnable Parameters
    >>> m = nn.BatchNorm3d(100, affine=False, process_group=process_group)
    >>> input = torch.randn(20, 100, 35, 45, 10)
    >>> output = m(input)

    >>> # network is nn.BatchNorm layer
    >>> sync_bn_network = nn.SyncBatchNorm.convert_sync_batchnorm(network, process_group)
    >>> # only single gpu per process is currently supported
    >>> ddp_sync_bn_network = torch.nn.parallel.DistributedDataParallel(
    >>>                         sync_bn_network,
    >>>                         device_ids=[args.local_rank],
    >>>                         output_device=args.local_rank)
Tr   c                ód   <€ V ^8„  d   QhRS[ RS[RS[R,          RS[RS[RS[R,          RS[R	R/# )
r   r   r   r   Nr   r   Úprocess_groupr   r   )r!   r"   r#   r   )r$   r%   s   "€r&   r'   ÚSyncBatchNorm.__annotate__ó  sc   ø€ ÷ +ñ +áð+ñ ð+ñ ˜$•,ð	+ñ
 ð+ñ "ð+ñ ˜T•zð+ñ ð+ð 
ñ+r)   c	               óR   <€ R VRV/p
\         SV `  ! VVVVV3/ V
BRV	/B  W`n        R# rƒ   )r2   r3   r×   )r>   r   r   r   r   r   r×   r+   r,   r   r?   rB   s   &&&&&&&&&$ €r&   r3   ÚSyncBatchNorm.__init__ó  sK   ø€ ð # F¨G°UÐ;ˆÜ‰ÒØØØØØñ	
ð ñ	
ð ó	
ð +Ör)   c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   rØ     s   ø€ ÷ Wñ W¨ñ Wr)   c                ój   € VP                  4       ^8  d   \        RVP                  4        R24      hR# )r   z expected at least 2D input (got r«   Nr¬   rV   s   &&r&   rX   ÚSyncBatchNorm._check_input_dim  s/   € Ø�9‰9‹;˜Œ?ÜÐ?ÀÇ	Á	Ã¸}ÈHÐUÓVÐVñ r)   c                ó   <€ V ^8„  d   QhRR/# rE   rF   )r$   r%   s   "€r&   r'   rØ     s   ø€ ÷ ñ °tñ r)   c                óH   € VP                  ^4      ^ 8X  d   \        R4      hR# )rH   z9SyncBatchNorm number of input channels should be non-zeroN)Úsizer®   rV   s   &&r&   Ú_check_non_zero_input_channelsÚ,SyncBatchNorm._check_non_zero_input_channels  s'   € Ø�:‰:�a‹=˜AÔÜØKóð ñ r)   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# r†   r   )r$   r%   s   "€r&   r'   rØ     s   ø€ ÷ añ a™Vð a©ñ ar)   c                ót  € V P                  V4       V P                  V4       V P                  f   RpMV P                  pV P                  '       dƒ   V P                  '       dq   V P
                  f   \        R4      hV P
                  P                  ^4       V P                  f#   RV P
                  P                  4       ,          pMV P                  p V P                  '       d   RpM$V P                  RJ ;'       d    V P                  RJ p V P                  '       d   V P                  '       d   V P                  MRpV P                  '       d   V P                  '       d   V P                  MRpT;'       dY    V P                  ;'       dE    \        P                  P                  4       ;'       d    \        P                  P                  4       pV'       dÌ   VP                  P                   RRR\        P"                  P%                  4       39  d+   \'        R	\        P"                  P%                  4        24      h\        P                  P(                  P*                  pV P,                  '       d   V P,                  p\        P                  P/                  V4      pV^8„  pV'       g<   \0        P2                  ! VVVV P4                  V P6                  VVV P8                  4      # V'       g   \        R
4      h\:        P<                  ! VV P4                  V P6                  VVV P8                  VXX4	      # )z
Runs the forward pass.
Nrˆ   z$num_batches_tracked must not be Noner‰   TÚcudaÚhpuÚxpuz;SyncBatchNorm expected input tensor to be on GPU or XPU or zbn_training must be True)rX   rá   r   rŠ   r   r0   r    r‹   Úitemr.   r/   r4   ÚdistributedÚis_availableÚis_initializedr+   ÚtypeÚ_CÚ_get_privateuse1_backend_namer®   ÚgroupÚWORLDr×   Úget_world_sizerŒ   r�   r-   r   r   Úsync_batch_normÚapply)	r>   rW   rŽ   r�   r.   r/   Ú	need_syncr×   Ú
world_sizes	   &&       r&   r�   ÚSyncBatchNorm.forward  s¼  € ð 	×Ñ˜eÔ$Ø×+Ñ+¨EÔ2ð
 �=‰=Ò Ø),Ñ&à)-¯©Ð&à�=�=ˆ=˜T×5×5Ð5Ø×'Ñ'Ò/Ü$Ð%KÓLÐLØ×$Ñ$×)Ñ)¨!Ô,Ø�}‰}Ò$Ø-0°4×3KÑ3K×3PÑ3PÓ3RÕ-RÑ*à-1¯]©]Ð*ð	ð �=�=ˆ=Ø‰Kà×,Ñ,°Ð4×TÐT¸4×;KÑ;KÈtÐ;SˆKð	ð &*§]§] ]°d×6N×6NÐ6NˆD×ÒÐTXð 	ð %)§M§M M°T×5M×5MÐ5MˆD×ÒÐSWð 	ð ÷ 3ð 3Ø—‘÷3ð 3ä×!Ñ!×.Ñ.Ó0÷3ð 3ô ×!Ñ!×0Ñ0Ó2ð	 	÷ à�|‰|× Ñ ØØØÜ—‘×6Ñ6Ó8ð	)ô ô !ØQÜ—x‘x×=Ñ=Ó?Ð@ðBóð ô
 "×-Ñ-×3Ñ3×9Ñ9ˆMØ×!×!Ð!Ø $× 2Ñ 2�Ü×*Ñ*×9Ñ9¸-ÓHˆJØ" Q™ˆI÷ Ü—<’<ØØØØ—‘Ø—	‘	ØØ*Ø—‘ó	ð 	÷ Ü$Ð%?Ó@Ð@Ü"×(Ò(ØØ—‘Ø—	‘	ØØØ—‘Ø*ØØó
ð 
r)   c           
     ól  € Tp\        V\        P                  P                  P                  P
                  4      '       Ed&   \        P                  P                  VP                  VP                  VP                  VP                  VP                  VVP                  RJR7      pVP                  '       dI   \        P                  ! 4       ;_uu_ 4        VP                  Vn        VP                  Vn        RRR4       VP                  Vn        VP                   Vn        VP"                  Vn        VP$                  Vn        \'        VR4      '       d   VP(                  Vn        VP+                  4        F%  w  rEVP-                  W@P/                  WR4      4       K'  	  ?V#   + '       g   i     L³; i)a�  Converts all :attr:`BatchNorm*D` layers in the model to :class:`torch.nn.SyncBatchNorm` layers.

Args:
    module (nn.Module): module containing one or more :attr:`BatchNorm*D` layers
    process_group (optional): process group to scope synchronization,
        default is the whole world

Returns:
    The original :attr:`module` with the converted :class:`torch.nn.SyncBatchNorm`
    layers. If the original :attr:`module` is a :attr:`BatchNorm*D` layer,
    a new :class:`torch.nn.SyncBatchNorm` layer object will be returned
    instead.

Example::

    >>> # Network with nn.BatchNorm layer
    >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CUDA)
    >>> module = torch.nn.Sequential(
    >>>            torch.nn.Linear(20, 100),
    >>>            torch.nn.BatchNorm1d(100),
    >>>          ).cuda()
    >>> # creating process group (optional)
    >>> # ranks is a list of int identifying rank ids.
    >>> ranks = list(range(8))
    >>> r1, r2 = ranks[:4], ranks[4:]
    >>> # Note: every rank calls into new_group for every
    >>> # process group created, even if that rank is not
    >>> # part of the group.
    >>> # xdoctest: +SKIP("distributed")
    >>> process_groups = [torch.distributed.new_group(pids) for pids in [r1, r2]]
    >>> process_group = process_groups[0 if dist.get_rank() <= 3 else 1]
    >>> sync_bn_module = torch.nn.SyncBatchNorm.convert_sync_batchnorm(module, process_group)

N)r   Úqconfig)rŸ   r4   ÚnnÚmodulesÚ	batchnormr   r   r   r   r   r   r   r   Úno_gradr-   r.   r/   r0   rŠ   Úhasattrrø   Únamed_childrenÚ
add_moduleÚconvert_sync_batchnorm)ÚclsÚmoduler×   Úmodule_outputÚnameÚchilds   &&&   r&   r   Ú$SyncBatchNorm.convert_sync_batchnormy  sD  € ðH ˆÜ�fœeŸh™h×.Ñ.×8Ñ8×CÑC×DÓDÜ!ŸH™H×2Ñ2Ø×#Ñ#Ø—
‘
Ø—‘Ø—‘Ø×*Ñ*ØØ—[‘[¨Ð,ð 3ó ˆMð �}�}ˆ}Ü—]’]—_•_Ø+1¯=©=�MÔ(Ø)/¯©�MÔ&÷ %ð *0×)<Ñ)<ˆMÔ&Ø(.×(:Ñ(:ˆMÔ%Ø06×0JÑ0JˆMÔ-Ø%+§_¡_ˆMÔ"Ü�v˜y×)Ò)Ø(.¯©�Ô%Ø!×0Ñ0Ö2‰KˆDØ×$Ñ$Ø×0Ñ0°ÓFöñ 3ð ØÐ÷ %—_ús   Ã#F#Æ#F3	)r×   )rp   rq   TTNNNrP   )rr   rs   rt   ru   rv   r3   rX   rá   r�   Úclassmethodr   rz   r{   r|   r}   s   @@r&   r   r   Š  s\   ù‡ € ñfñP+ð ÷+ö +÷2Wð W÷ð ÷að aðF ó=ó ÷=ð =r)   )r   r   r   r   r   r   r   )Útypingr   r4   r   Útorch.nnr   rŒ   r   Útorch.nn.parameterr   r	   r
   Ú
_functionsr   rò   Úlazyr   r  r   Ú__all__r   r   r“   r   r   r   r   r   r   rF   r)   r&   Ú<module>r     sÊ   ðå ã Ý ß *ß UÑ Uå 8Ý !Ý ò€ô|
�ô |
ô~H
�ô H
ôVL$�O Yô L$ô^KT�*ô KTô\!T�m Zô !TôHLN�*ô LNô^!N�m Zô !NôHLN�*ô LNô^!N�m Zô !NôHm�Jö mr)   