+
    ˜°³jág  ã                   óž  € R t ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
t
^ RI
Ht . R6Ot]! R4      t]	! R4      t]R7,          t]R8,          tR9R R	 lltR9R
 R lltR9R R lltR R ltR R ltR9R R lltR:R R lltR:R R lltR;R R lltR R ltR R ltR R ltR  R! ltR<R" R# lltR$ R% ltR=R& R' llt R=R( R) llt!R* R+ lt"R>R, R- llt#R>R. R/ llt$R?R0 R1 llt%R@R2 R3 llt&R4 R5 lt']'! ]4      t(]'! ]4      t)]'! ]4      t*]'! ]4      t+]'! ]4      t,]'! ] 4      t-]'! ]!4      t.]'! ]#4      t/]'! ]$4      t0]'! ]%4      t1]'! ]&4      t2R# )AzHThis file contains utilities for initializing neural network parameters.N)ÚCallable)ÚLiteralÚTypeVar)Ú	ParamSpec©ÚTensorÚ_RÚ_Pc          
      óv   € V ^8„  d   QhR\         R\        R\        R\        P                  R,          R\         /# ©é   ÚtensorÚaÚbÚ	generatorNÚreturn©r   ÚfloatÚtorchÚ	Generator)Úformats   "ÚN/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/nn/init.pyÚ__annotate__r   E   s=   € ÷ :ñ :Üð:Üð:Ü!&ð:Ü38·?±?ÀTÕ3Ið:äñ:ó    c                 ó    € \         P                  ! 4       ;_uu_ 4        V P                  WVR 7      uuRRR4       #   + '       g   i     R# ; i©©r   N)r   Úno_gradÚuniform_©r   r   r   r   s   &&&&r   Ú_no_grad_uniform_r    E   s+   € ô 
�Š��Ø�‰˜q¨yˆÓ9÷ 
��‹úó	   ž<¼A	c          
      óv   € V ^8„  d   QhR\         R\        R\        R\        P                  R,          R\         /# ©r   r   ÚmeanÚstdr   Nr   r   )r   s   "r   r   r   L   sC   € ÷ >ñ >Üð>ä
ð>ô 
ð>ô �‰ Õ%ð	>ô
 ñ>r   c                 ó    € \         P                  ! 4       ;_uu_ 4        V P                  WVR 7      uuRRR4       #   + '       g   i     R# ; ir   )r   r   Únormal_©r   r$   r%   r   s   &&&&r   Ú_no_grad_normal_r)   L   s+   € ô 
�Š��Ø�~‰~˜d°9ˆ~Ó=÷ 
��‹úr!   c                óŽ   € V ^8„  d   QhR\         R\        R\        R\        R\        R\        P                  R,          R\         /# ©	r   r   r$   r%   r   r   r   Nr   r   )r   s   "r   r   r   V   s`   € ÷ Jñ JÜðJä
ðJô 
ðJô ð	Jô
 ðJô �‰ Õ%ðJô ñJr   c                 ó<  € V P                   '       d   V # R  R lpW^V,          ,
          8  g   W^V,          ,           8”  d   \        P                  ! R^R7       \        P                  ! 4       ;_uu_ 4        V! WA,
          V,          4      V! W1,
          V,          4      ,
          pVR8”  dÒ   V P                  VRR7      P                  4       pV P                  VRR7      P                  4       p	V P                  WVR7      p
 W¨8  W©8„  ,          pVP                  4       '       g   M?\        P                  ! V\        P                  ! V
4      P                  WVR7      V
4      p
Kd  W
Jd   V P                  V
4       EMþ\        V\        W4      4      pR	WÁ,
          V,          ^,          ,          p\        P                  ! V 4      p\        P                  ! V 4      pV P                  W4VR7       VP                  V 4       VP                  V4      P!                  V4      P#                  ^4      P%                  R	4      P                  V4       VP                  VR7      P'                  4       P)                  V4      pVP                  4       '       g   MéT p
 VP                  W4VR7       \        P                  ! VWê4      p
VP                  V4      P!                  V4      P#                  ^4      P%                  R	4      P                  V4       \        P                  ! VVP                  VR7      P'                  4       P)                  V4      V4      pVP                  4       '       d   KÕ   T P                  T
4       V uuRRR4       #   + '       g   i     R# ; i)
c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úxr   )r   )r   s   "r   r   Ú,_no_grad_trunc_normal_.<locals>.__annotate__b   s   € ÷ :ñ :”Eð :œeñ :r   c                 ó€   € R \         P                  ! V \         P                  ! R4      ,          4      ,           R,          # )ç      ð?ç       @)ÚmathÚerfÚsqrt)r.   s   &r   Únorm_cdfÚ(_no_grad_trunc_normal_.<locals>.norm_cdfb   s(   € Ø”d—h’h˜q¤4§9¢9¨S£>Õ1Ó2Õ2°cÕ9Ð9r   zjmean is more than 2 std from [a, b] in nn.init.trunc_normal_. The distribution of values may be incorrect.©Ú
stacklevelg333333Ó?Úcpu)Údevicer   Ng      à¿)Úis_metaÚwarningsÚwarnr   r   Ú
new_tensorÚitemr'   ÚanyÚwhereÚ
empty_likeÚcopy_ÚmaxÚminr   Úsub_Údiv_Úpow_Úmul_Úlog_Úgt)r   r$   r%   r   r   r   r6   ÚpÚloÚhiÚresultÚmaskÚmodeÚlog_peakÚ
candidatesÚ
accept_bufÚpendings   &&&&&&           r   Ú_no_grad_trunc_normal_rW   V   sÏ  € ð ‡~‡~€~Øˆõ:ð 	�1�s•7�{Ô ¨1¨s­7¥{Ô 2Ü�Šð;àõ	
ô 
�Š��Ù�a•h #Õ%Ó&©°1µ8¸sÕ2BÓ)CÕCˆàˆsŒ7ð ×"Ñ" 1¨UÐ"Ó3×8Ñ8Ó:ˆBØ×"Ñ" 1¨UÐ"Ó3×8Ñ8Ó:ˆBØ—^‘^ D¸�^ÓCˆFØØ™¨©Õ4�Ø—x‘x—z’zØÜŸšØÜ×$Ò$ VÓ,×4Ñ4°TÈ)Ð4ÓTØó’ð
 Ó#Ø—‘˜VÔ$ùä�qœ#˜d›,Ó'ˆDØ ¥¨sÕ2°qÕ8Õ8ˆHä×)Ò)¨&Ó1ˆJÜ×)Ò)¨&Ó1ˆJð �O‰O˜A¨IˆOÔ6Ø×Ñ˜VÔ$à�O‰O˜DÓ!×&Ñ& sÓ+×0Ñ0°Ó3×8Ñ8¸Ó>×CÑCÀHÔMØ ×)Ñ)°IÐ)Ó>×CÑCÓE×HÑHÈÓTˆGØ—;‘;—=’=Øà�ØØ×'Ñ'¨¸	Ð'ÔBÜ"Ÿ[š[¨°*ÓE�Fà—O‘O DÓ)×.Ñ.¨sÓ3×8Ñ8¸Ó;×@Ñ@ÀÓF×KÑKÈHÔUÜ#ŸkškØØ"×+Ñ+°iÐ+Ó@×EÑEÓG×JÑJÈ:ÓVØó�Gð
 #Ÿ;™;Ÿ=œ=ØØ—‘˜VÔ$à÷i 
��‹ús   Á8K/N
Í,N
Î
N	c                ó<   € V ^8„  d   QhR\         R\        R\         /# ©r   r   Úvalr   ©r   r   )r   s   "r   r   r   £   s!   € ÷ !ñ !œ6ð !¬ð !´&ñ !r   c                 óœ   € \         P                  ! 4       ;_uu_ 4        V P                  V4      uuR R R 4       #   + '       g   i     R # ; i©N)r   r   Úfill_©r   rZ   s   &&r   Ú_no_grad_fill_r`   £   s%   € Ü	�Š��Ø�|‰|˜CÓ ÷ 
��‹ús	   ž:ºA	c                ó0   € V ^8„  d   QhR\         R\         /# ©r   r   r   r   )r   s   "r   r   r   ¨   s   € ÷ ñ œ6ð ¤fñ r   c                 óš   € \         P                  ! 4       ;_uu_ 4        V P                  4       uuR R R 4       #   + '       g   i     R # ; ir]   )r   r   Úzero_©r   s   &r   Ú_no_grad_zero_rf   ¨   s"   € Ü	�Š��Ø�|‰|‹~÷ 
��‹ús	   ž9¹A
	c                ó`   € V ^8„  d   QhR\         R\        \        ,          R,          R\        /# )r   ÚnonlinearityÚparamNr   )Ú_NonlinearityTypeÚintr   )r   s   "r   r   r   ­   s7   € ÷ GEñ GEÜ#ðGEÜ,/´%­K¸$Õ,>ðGEä
ñGEr   c                ó¼  € . ROpW9   g   V R8X  d   ^# V R8X  d   R# V R8X  d   \         P                  ! R4      # V R8X  d‡   Vf   RpMT\        V\        4      '       g   \        V\        4      '       g   \        V\
        4      '       d   TpM\        RV R24      h\         P                  ! R^V^,          ,           ,          4      # V R	8X  d   R# \        R
V  24      h)al  Return the recommended gain value for the given nonlinearity function.

The values are as follows:

================= ====================================================
nonlinearity      gain
================= ====================================================
Linear / Identity :math:`1`
Conv{1,2,3}D      :math:`1`
Sigmoid           :math:`1`
Tanh              :math:`\frac{5}{3}`
ReLU              :math:`\sqrt{2}`
Leaky Relu        :math:`\sqrt{\frac{2}{1 + \text{negative\_slope}^2}}`
SELU              :math:`\frac{3}{4}`
================= ====================================================

.. warning::
    In order to implement `Self-Normalizing Neural Networks
    <https://papers.nips.cc/paper/2017/hash/5d44ee6f2c3f71b73125876103c8f6c4-Abstract.html>`__,
    you should use ``nonlinearity='linear'`` instead of ``nonlinearity='selu'``.
    This gives the initial weights a variance of ``1 / N``,
    which is necessary to induce a stable fixed point in the forward pass.
    In contrast, the default gain for ``SELU`` sacrifices the normalization
    effect for more stable gradient flow in rectangular layers.

Args:
    nonlinearity: the non-linear function (`nn.functional` name)
    param: optional parameter for the non-linear function

Examples:
    >>> gain = nn.init.calculate_gain(
    ...     "leaky_relu", 0.2
    ... )  # leaky_relu with negative_slope=0.2

ÚsigmoidÚtanhÚrelur2   Ú
leaky_reluç{®Gáz„?znegative_slope z not a valid numberÚseluzUnsupported nonlinearity )ÚlinearÚconv1dÚconv2dÚconv3dÚconv_transpose1dÚconv_transpose2dÚconv_transpose3dg«ªªªªªú?g      è?)r3   r5   Ú
isinstanceÚboolrk   r   Ú
ValueError)rh   ri   Ú
linear_fnsÚnegative_slopes   &&  r   Úcalculate_gainr   ­   s×   € òL€Jð Ô! \°YÔ%>ÙØ	˜Ô	ØˆØ	˜Ô	Ü�yŠy˜‹~ÐØ	˜Ô	%ØŠ=Ø!‰Nä˜5¤$×'Ò'Ü˜5¤#×&Ò&Ü˜%¤×'Ò'ð #‰Nä˜¨u¨gÐ5HÐIÓJÐJÜ�yŠy˜  N°AÕ$5Õ 5Õ6Ó7Ð7Ø	˜Ô	àð	
ô Ð4°\°NÐCÓDÐDr   c          
      óv   € V ^8„  d   QhR\         R\        R\        R\        P                  R,          R\         /# r   r   )r   s   "r   r   r   ÷   sC   € ÷ 6ñ 6Üð6äð6ô ð6ô �‰ Õ%ð	6ô
 ñ6r   c           	     ó´   € \         P                  P                  V 4      '       d)   \         P                  P                  \        V 3WW#R7      # \        WW#4      # )aƒ  Fill the input Tensor with values drawn from the uniform distribution.

:math:`\mathcal{U}(a, b)`.

Args:
    tensor: an n-dimensional `torch.Tensor`
    a: the lower bound of the uniform distribution
    b: the upper bound of the uniform distribution
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.uniform_(w)
r   )r   Ú	overridesÚhas_torch_function_variadicÚhandle_torch_functionr   r    r   s   &&&&r   r   r   ÷   sO   € ô( ‡�×2Ñ2°6×:Ò:Ü�‰×4Ñ4Ü�v�i¨°qð 5ó 
ð 	
ô ˜V¨Ó5Ð5r   c          
      óv   € V ^8„  d   QhR\         R\        R\        R\        P                  R,          R\         /# r#   r   )r   s   "r   r   r     sC   € ÷ :ñ :Üð:ä
ð:ô 
ð:ô �‰ Õ%ð	:ô
 ñ:r   c           	     ó´   € \         P                  P                  V 4      '       d)   \         P                  P                  \        V 3WW#R7      # \        WW#4      # )a™  Fill the input Tensor with values drawn from the normal distribution.

:math:`\mathcal{N}(\text{mean}, \text{std}^2)`.

Args:
    tensor: an n-dimensional `torch.Tensor`
    mean: the mean of the normal distribution
    std: the standard deviation of the normal distribution
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.normal_(w)
r(   )r   r‚   rƒ   r„   r'   r)   r(   s   &&&&r   r'   r'     sO   € ô( ‡�×2Ñ2°6×:Ò:Ü�‰×4Ñ4Ü�f�Y v¸cð 5ó 
ð 	
ô ˜F¨#Ó9Ð9r   c                óŽ   € V ^8„  d   QhR\         R\        R\        R\        R\        R\        P                  R,          R\         /# r+   r   )r   s   "r   r   r   -  s`   € ÷ !Pñ !PÜð!Pä
ð!Pô 
ð!Pô ð	!Pô
 ð!Pô �‰ Õ%ð!Pô ñ!Pr   c           	     ó   € \        WW#WER7      # )aÆ  Fill the input Tensor with values drawn from a truncated normal distribution.

The values are effectively drawn from the
normal distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)`
with values outside :math:`[a, b]` redrawn until they are within
the bounds. The method used for generating the random values works
best when :math:`a \leq \text{mean} \leq b`.

For reduced-precision types (``torch.float16`` and ``torch.bfloat16``),
sampling quality depends on the underlying ``normal_()`` and ``uniform_()``
implementations which operate at higher internal precision to avoid
quantization artifacts.

Args:
    tensor: an n-dimensional `torch.Tensor`
    mean: the mean of the normal distribution
    std: the standard deviation of the normal distribution
    a: the minimum cutoff value
    b: the maximum cutoff value
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.trunc_normal_(w)
r   )rW   )r   r$   r%   r   r   r   s   &&&&&&r   Útrunc_normal_r‰   -  s   € ôB " &°¸ÔOÐOr   c                ó<   € V ^8„  d   QhR\         R\        R\         /# rY   r[   )r   s   "r   r   r   Q  s!   € ÷ 'ñ '”fð '¤5ð '¬Vñ 'r   c                ó°   € \         P                  P                  V 4      '       d(   \         P                  P                  \        V 3WR7      # \        W4      # )zâFill the input Tensor with the value :math:`\text{val}`.

Args:
    tensor: an n-dimensional `torch.Tensor`
    val: the value to fill the tensor with

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.constant_(w, 0.3)
r_   )r   r‚   rƒ   r„   Ú	constant_r`   r_   s   &&r   rŒ   rŒ   Q  sK   € ô ‡�×2Ñ2°6×:Ò:Ü�‰×4Ñ4Ü˜�y¨ð 5ó 
ð 	
ô ˜&Ó&Ð&r   c                ó0   € V ^8„  d   QhR\         R\         /# rb   r   )r   s   "r   r   r   c  s   € ÷ 
'ñ 
'”&ð 
'œVñ 
'r   c                ó   € \        V R4      # )z¦Fill the input Tensor with the scalar value `1`.

Args:
    tensor: an n-dimensional `torch.Tensor`

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.ones_(w)
r1   )r`   re   s   &r   Úones_r�   c  s   € ô ˜& #Ó&Ð&r   c                ó0   € V ^8„  d   QhR\         R\         /# rb   r   )r   s   "r   r   r   p  s   € ÷ 
"ñ 
"”6ð 
"œfñ 
"r   c                ó   € \        V 4      # )z§Fill the input Tensor with the scalar value `0`.

Args:
    tensor: an n-dimensional `torch.Tensor`

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.zeros_(w)
)rf   re   s   &r   Úzeros_r’   p  s   € ô ˜&Ó!Ð!r   c                ó0   € V ^8„  d   QhR\         R\         /# rb   r   )r   s   "r   r   r   }  s   € ÷ ñ ”ð œFñ r   c           	     ó  € V P                  4       ^8w  d   \        R4      h\        P                  ! 4       ;_uu_ 4        \        P                  ! V P
                  RV RV P                  /  RRR4       V #   + '       g   i     T # ; i)a  Fill the 2-dimensional input `Tensor` with the identity matrix.

Preserves the identity of the inputs in `Linear` layers, where as
many inputs are preserved as possible.

Args:
    tensor: a 2-dimensional `torch.Tensor`

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.eye_(w)
ú,Only tensors with 2 dimensions are supportedÚoutÚrequires_gradN)Ú
ndimensionr|   r   r   ÚeyeÚshaper—   re   s   &r   Úeye_r›   }  sc   € ð ×ÑÓ˜aÔÜÐGÓHÐHä	�Š��Ü�	Š	�6—<‘<ÐP VÐP¸6×;OÑ;OÒP÷ 
à€M÷ 
Žà€Mús   ¾-A5Á5B	c                ó<   € V ^8„  d   QhR\         R\        R\         /# )r   r   Úgroupsr   )r   rk   )r   s   "r   r   r   ’  s!   € ÷ 5ñ 5”6ð 5¤3ð 5¬vñ 5r   c                ó   € V P                  4       pVR9  d   \        R4      hV P                  4       pV^ ,          V,          ^ 8w  d   \        R4      hV P                  '       d   V # V^ ,          V,          p\	        WC^,          4      p\
        P                  ! 4       ;_uu_ 4        V P                  4        \        V4       Fì  p\        V4       FÚ  pV^8X  d-   ^WV,          V,           WpP                  ^4      ^,          3&   K6  V^8X  dE   ^V Wd,          V,           VV P                  ^4      ^,          V P                  ^4      ^,          3&   K�  ^V Wd,          V,           VV P                  ^4      ^,          V P                  ^4      ^,          V P                  ^4      ^,          3&   KÜ  	  Kî  	  RRR4       V #   + '       g   i     T # ; i)a  Fill the {3, 4, 5}-dimensional input `Tensor` with the Dirac delta function.

Preserves the identity of the inputs in `Convolutional`
layers, where as many input channels are preserved as possible. In case
of groups>1, each group of channels preserves identity

Args:
    tensor: a {3, 4, 5}-dimensional `torch.Tensor`
    groups (int, optional): number of groups in the conv layer (default: 1)
Examples:
    >>> w = torch.empty(3, 16, 5, 5)
    >>> nn.init.dirac_(w)
    >>> w = torch.empty(3, 24, 5, 5)
    >>> nn.init.dirac_(w, 3)
z5Only tensors with 3, 4, or 5 dimensions are supportedz!dim 0 must be divisible by groupsN)é   é   é   )	r˜   r|   Úsizer<   rF   r   r   rd   Úrange)r   r�   Ú
dimensionsÚsizesÚout_chans_per_grpÚmin_dimÚgÚds   &&      r   Údirac_rª   ’  sŒ  € ð  ×"Ñ"Ó$€JØ˜Ô"ÜÐPÓQÐQà�K‰K‹M€EàˆQ…x�&Õ˜AÔÜÐ<Ó=Ð=à‡~‡~€~Øˆà˜a� FÕ*ÐÜÐ#¨1¥XÓ.€Gä	�Š��Ø�‰Œä�v–ˆAÜ˜7–^�Ø ”?ØPQ�FÐ0Õ0°1Õ4°a¿¹ÀQ»È1Õ9LÐLÓMØ 1”_ð ð ØÕ-°Õ1ØØŸ™ A›¨!Õ+ØŸ™ A›¨!Õ+ð-óð ð ØÕ-°Õ1ØØŸ™ A›¨!Õ+ØŸ™ A›¨!Õ+ØŸ™ A›¨!Õ+ð	-óó $ñ ÷ 
ð, €M÷- 
Žð, €Mús   Â&DF<Æ<G	c                óR   € V ^8„  d   QhR\         R\        \        \        3,          /# rb   )r   Útuplerk   )r   s   "r   r   r   Ê  s"   € ÷ ñ ¬&ð ´U¼3Ä¸8µ_ñ r   c                 ó"  € V P                  4       pV^8  d   \        R4      hV P                  ^4      pV P                  ^ 4      p^pV P                  4       ^8”  d#   V P                  R,           F  pWE,          pK  	  W$,          pW4,          pWg3# )r   zNFan in and fan out can not be computed for tensor with fewer than 2 dimensions:r   NN)Údimr|   r¢   rš   )r   r¤   Únum_input_fmapsÚnum_output_fmapsÚreceptive_field_sizeÚsÚfan_inÚfan_outs   &       r   Ú_calculate_fan_in_and_fan_outrµ   Ê  sŽ   € Ø—‘“€JØ�A„~ÜØ\ó
ð 	
ð —k‘k !“n€OØ—{‘{ 1“~ÐØÐØ‡z�zƒ|�aÔð —‘˜b×!Ð!ˆAØ Õ%Ò ñ "àÕ3€FØÕ5€Gàˆ?Ðr   c                ój   € V ^8„  d   QhR\         R\        R\        P                  R,          R\         /# ©r   r   Úgainr   Nr   r   )r   s   "r   r   r   ß  s9   € ÷ 7ñ 7Üð7ä
ð7ô �‰ Õ%ð7ô ñ	7r   c                óÖ   € \        V 4      w  r4V\        P                  ! R\        W4,           4      ,          4      ,          p\        P                  ! R4      V,          p\	        W) Wb4      # )a°  Fill the input `Tensor` with values using a Xavier uniform distribution.

The method is described in `Understanding the difficulty of training
deep feedforward neural networks` - Glorot, X. & Bengio, Y. (2010).
The resulting tensor will have values sampled from
:math:`\mathcal{U}(-a, a)` where

.. math::
    a = \text{gain} \times \sqrt{\frac{6}{\text{fan\_in} + \text{fan\_out}}}

Also known as Glorot initialization.

Args:
    tensor: an n-dimensional `torch.Tensor`
    gain: an optional scaling factor
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.xavier_uniform_(w, gain=nn.init.calculate_gain("relu"))
r2   ç      @)rµ   r3   r5   r   r    )r   r¸   r   r³   r´   r%   r   s   &&&    r   Úxavier_uniform_r»   ß  sQ   € ô4 4°FÓ;�O€FØ
”—’˜3¤ vÕ'7Ó!8Õ8Ó9Õ
9€CÜ�	Š	�#‹˜Õ€Aä˜V R¨Ó6Ð6r   c                ój   € V ^8„  d   QhR\         R\        R\        P                  R,          R\         /# r·   r   )r   s   "r   r   r      s9   € ÷ 9ñ 9Üð9ä
ð9ô �‰ Õ%ð9ô ñ	9r   c                óœ   € \        V 4      w  r4V\        P                  ! R\        W4,           4      ,          4      ,          p\	        V RWR4      # )aœ  Fill the input `Tensor` with values using a Xavier normal distribution.

The method is described in `Understanding the difficulty of training deep feedforward
neural networks` - Glorot, X. & Bengio, Y. (2010). The resulting tensor
will have values sampled from :math:`\mathcal{N}(0, \text{std}^2)` where

.. math::
    \text{std} = \text{gain} \times \sqrt{\frac{2}{\text{fan\_in} + \text{fan\_out}}}

Also known as Glorot initialization.

Args:
    tensor: an n-dimensional `torch.Tensor`
    gain: an optional scaling factor
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.xavier_normal_(w)
r2   ç        )rµ   r3   r5   r   r)   )r   r¸   r   r³   r´   r%   s   &&&   r   Úxavier_normal_r¿      s?   € ô2 4°FÓ;�O€FØ
”—’˜3¤ vÕ'7Ó!8Õ8Ó9Õ
9€Cä˜F C¨Ó8Ð8r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   r   rR   r   )r   Ú_FanModerk   )r   s   "r   r   r     s!   € ÷ 3ñ 3¤6ð 3´ð 3¼cñ 3r   c                 óˆ   € VP                  4       pR R.pW9  d   \        RV RV 24      h\        V 4      w  r4VR 8X  d   V# T# )r³   r´   zMode z" not supported, please use one of )Úlowerr|   rµ   )r   rR   Úvalid_modesr³   r´   s   &&   r   Ú_calculate_correct_fanrÅ     sT   € à�:‰:‹<€DØ˜YÐ'€KØÔÜ˜5  Ð&HÈÈÐVÓWÐWä3°FÓ;�O€FØ˜XÔ%ˆ6Ð2¨7Ð2r   c                ó‚   € V ^8„  d   QhR\         R\        R\        R\        R\        P
                  R,          R\         /# ©r   r   r   rR   rh   r   Nr   ©r   r   rÁ   rj   r   r   )r   s   "r   r   r   *  sU   € ÷ >Cñ >CÜð>Cäð>Cô ð>Cô $ð	>Cô
 �‰ Õ%ð>Cô ñ>Cr   c           
     ó8  € \         P                  P                  V 4      '       d,   \         P                  P                  \        V 3V VVVVR7      # ^ V P
                  9   d   \        P                  ! R^R7       V # \        W4      p\        W14      pV\        P                  ! V4      ,          p\        P                  ! R4      V,          p\         P                  ! 4       ;_uu_ 4        V P                  V) W„R7      uuRRR4       #   + '       g   i     R# ; i)aD  Fill the input `Tensor` with values using a Kaiming uniform distribution.

The method is described in `Delving deep into rectifiers: Surpassing
human-level performance on ImageNet classification` - He, K. et al. (2015).
The resulting tensor will have values sampled from
:math:`\mathcal{U}(-\text{bound}, \text{bound})` where

.. math::
    \text{bound} = \text{gain} \times \sqrt{\frac{3}{\text{fan\_mode}}}

Also known as He initialization.

Args:
    tensor: an n-dimensional `torch.Tensor`
    a: the negative slope of the rectifier used after this layer (only
        used with ``'leaky_relu'``)
    mode: either ``'fan_in'`` (default) or ``'fan_out'``. Choosing ``'fan_in'``
        preserves the magnitude of the variance of the weights in the
        forward pass. Choosing ``'fan_out'`` preserves the magnitudes in the
        backwards pass.
    nonlinearity: the non-linear function (`nn.functional` name),
        recommended to use only with ``'relu'`` or ``'leaky_relu'`` (default).
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.kaiming_uniform_(w, mode="fan_in", nonlinearity="relu")

Note:
    Be aware that ``fan_in`` and ``fan_out`` are calculated assuming
    that the weight matrix is used in a transposed manner,
    (i.e., ``x @ w.T`` in ``Linear`` layers, where ``w.shape = [fan_out, fan_in]``).
    This is important for correct initialization.
    If you plan to use ``x @ w``, where ``w.shape = [fan_in, fan_out]``,
    pass in a transposed weight matrix, i.e. ``nn.init.kaiming_uniform_(w.T, ...)``.
)r   r   rR   rh   r   ú,Initializing zero-element tensors is a no-opr8   rº   r   N)r   r‚   rƒ   r„   Úkaiming_uniform_rš   r=   r>   rÅ   r   r3   r5   r   r   )	r   r   rR   rh   r   Úfanr¸   r%   Úbounds	   &&&&&    r   rË   rË   *  sÑ   € ôV ‡�×2Ñ2°6×:Ò:Ü�‰×4Ñ4ÜØˆIØØØØ%Øð 5ó 
ð 	
ð 	ˆF�L‰LÔÜ�ŠÐDÐQRÕSØˆÜ
  Ó
.€CÜ˜,Ó*€DØ
”—’˜3“Õ
€CÜ�IŠI�c‹N˜SÕ €EÜ	�Š��Ø�‰ ˜v uˆÓB÷ 
��‹ús   Ã)DÄD	c                ó‚   € V ^8„  d   QhR\         R\        R\        R\        R\        P
                  R,          R\         /# rÇ   rÈ   )r   s   "r   r   r   k  sM   € ÷ 2;ñ 2;Üð2;äð2;ô ð2;ô $ð	2;ô
 �‰ Õ%ð2;ô ñ2;r   c                ó\  € ^ V P                   9   d   \        P                  ! R^R7       V # \        W4      p\	        W14      pV\
        P                  ! V4      ,          p\        P                  ! 4       ;_uu_ 4        V P                  ^ WtR7      uuRRR4       #   + '       g   i     R# ; i)a+  Fill the input `Tensor` with values using a Kaiming normal distribution.

The method is described in `Delving deep into rectifiers: Surpassing
human-level performance on ImageNet classification` - He, K. et al. (2015).
The resulting tensor will have values sampled from
:math:`\mathcal{N}(0, \text{std}^2)` where

.. math::
    \text{std} = \frac{\text{gain}}{\sqrt{\text{fan\_mode}}}

Also known as He initialization.

Args:
    tensor: an n-dimensional `torch.Tensor`
    a: the negative slope of the rectifier used after this layer (only
        used with ``'leaky_relu'``)
    mode: either ``'fan_in'`` (default) or ``'fan_out'``. Choosing ``'fan_in'``
        preserves the magnitude of the variance of the weights in the
        forward pass. Choosing ``'fan_out'`` preserves the magnitudes in the
        backwards pass.
    nonlinearity: the non-linear function (`nn.functional` name),
        recommended to use only with ``'relu'`` or ``'leaky_relu'`` (default).
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.kaiming_normal_(w, mode="fan_out", nonlinearity="relu")

Note:
    Be aware that ``fan_in`` and ``fan_out`` are calculated assuming
    that the weight matrix is used in a transposed manner,
    (i.e., ``x @ w.T`` in ``Linear`` layers, where ``w.shape = [fan_out, fan_in]``).
    This is important for correct initialization.
    If you plan to use ``x @ w``, where ``w.shape = [fan_in, fan_out]``,
    pass in a transposed weight matrix, i.e. ``nn.init.kaiming_normal_(w.T, ...)``.
rÊ   r8   r   N)
rš   r=   r>   rÅ   r   r3   r5   r   r   r'   )r   r   rR   rh   r   rÌ   r¸   r%   s   &&&&&   r   Úkaiming_normal_rÐ   k  ss   € ðV 	ˆF�L‰LÔÜ�ŠÐDÐQRÕSØˆÜ
  Ó
.€CÜ˜,Ó*€DØ
”—’˜3“Õ
€CÜ	�Š��Ø�~‰~˜a ˆ~Ó:÷ 
��‹ús   Á<BÂB+	c                ój   € V ^8„  d   QhR\         R\        R\        P                  R,          R\         /# r·   r   )r   s   "r   r   r      s9   € ÷ 0ñ 0Üð0ä
ð0ô �‰ Õ%ð0ô ñ	0r   c                óþ  € V P                  4       ^8  d   \        R4      hV P                  4       ^ 8X  g   V P                  '       d   V # V P	                  ^ 4      pV P                  4       V,          pV P                  W434      P                  ^ ^VR7      pW48  d   VP                  4        \        P                  P                  V4      w  rg\        P                  ! V^ 4      pVP                  4       p	Wi,          pW48  d   VP                  4        \        P                  ! 4       ;_uu_ 4        V P                  V4      P                  V4       V P!                  V4       RRR4       V #   + '       g   i     T # ; i)al  Fill the input `Tensor` with a (semi) orthogonal matrix.

Described in `Exact solutions to the nonlinear dynamics of learning in deep
linear neural networks` - Saxe, A. et al. (2013). The input tensor must have
at least 2 dimensions, and for tensors with more than 2 dimensions the
trailing dimensions are flattened.

Args:
    tensor: an n-dimensional `torch.Tensor`, where :math:`n \geq 2`
    gain: optional scaling factor
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_LAPACK)
    >>> w = torch.empty(3, 5)
    >>> nn.init.orthogonal_(w)
z4Only tensors with 2 or more dimensions are supportedr   N)r˜   r|   Únumelr<   r¢   Ú	new_emptyr'   Út_r   ÚlinalgÚqrÚdiagÚsignr   Úview_asrD   rJ   )
r   r¸   r   ÚrowsÚcolsÚ	flattenedÚqÚrr©   Úphs
   &&&       r   Úorthogonal_rá      s  € ð, ×ÑÓ˜QÔÜÐOÓPÐPà‡|�|ƒ~˜Ô˜fŸnŸn˜nàˆØ�;‰;�q‹>€DØ�<‰<‹>˜TÕ!€DØ× Ñ  $ Ó.×6Ñ6°q¸!ÀyÐ6ÓQ€Ià„{Ø�‰Œô �<‰<�?‰?˜9Ó%�D€Aä�
Š
�1�aÓ€AØ	
�‰‹€BØ…G€Aà„{Ø	�‰Œä	�Š��Ø�‰�qÓ×Ñ Ô"Ø�‰�DÔ÷ 
ð €M÷ 
Žð €Mús   Ä/2E+Å+E<	c          
      óv   € V ^8„  d   QhR\         R\        R\        R\        P                  R,          R\         /# )r   r   Úsparsityr%   r   Nr   r   )r   s   "r   r   r   Ó  sC   € ÷ &ñ &Üð&äð&ô 
ð&ô �‰ Õ%ð	&ô
 ñ&r   c                óÂ  € V P                  4       ^8w  d   \        R4      hV P                  '       d   V # V P                  w  rE\        P
                  ! W,          4      p\        P                  ! 4       ;_uu_ 4        V P                  ^ W#R7       \        V4       F$  p\        P                  ! V4      pVRV p	^ W	V3&   K&  	  RRR4       V #   + '       g   i     T # ; i)aZ  Fill the 2D input `Tensor` as a sparse matrix.

The non-zero elements will be drawn from the normal distribution
:math:`\mathcal{N}(0, 0.01)`, as described in `Deep learning via
Hessian-free optimization` - Martens, J. (2010).

Args:
    tensor: an n-dimensional `torch.Tensor`
    sparsity: The fraction of elements in each column to be set to zero
    std: the standard deviation of the normal distribution used to generate
        the non-zero values
    generator: the torch Generator to sample from (default: None)

Examples:
    >>> w = torch.empty(3, 5)
    >>> nn.init.sparse_(w, sparsity=0.1)
r•   r   N)r˜   r|   r<   rš   r3   Úceilr   r   r'   r£   Úrandperm)
r   rã   r%   r   rÛ   rÜ   Ú	num_zerosÚcol_idxÚrow_indicesÚzero_indicess
   &&&&      r   Úsparse_rë   Ó  sµ   € ð. ×ÑÓ˜aÔÜÐGÓHÐHà‡~‡~€~Øˆà—‘�J€DÜ—	’	˜(�/Ó*€Iä	�Š��Ø�‰�q˜#ˆÔ3Ü˜T–{ˆGÜŸ.š.¨Ó.ˆKØ& z¨	Ð2ˆLØ,-ˆF Ð(Ó)ñ #÷ 
ð €M÷ 
Žð €Mús   Á<ACÃC	c                ót   € V ^8„  d   QhR\         \        \        3,          R\         \        \        3,          /# )r   Úmethr   )r   r	   r   )r   s   "r   r   r   ý  s,   € ÷ ñ œ(¤2¤r 6Õ*ð ¬x¼¼B¸Õ/?ñ r   c                 ót   a aa€ S P                   oSR R oR V VV3R llpRS RS RS R2Vn        SVn         V# )Nc                ód   € V ^8„  d   QhR\         P                  R\         P                  R\        /# )r   ÚargsÚkwargsr   )r	   rð   rñ   r   )r   s   "r   r   Ú%_make_deprecate.<locals>.__annotate__  s)   € ÷ %ñ %œrŸw™wð %´"·)±)ð %Äñ %r   c                  ó\   <€ \         P                  ! R S RS R2\        ^R7       S! V / VB # )z	`nn.init.z)` is now deprecated in favor of `nn.init.z`.r8   )r=   r>   ÚFutureWarning)rð   rñ   rí   Únew_nameÚold_names   *,€€€r   Údeprecated_initÚ(_make_deprecate.<locals>.deprecated_init  s;   ø€ Ü�ŠØ˜�zÐ!JÈ8È*ÐTVÐWÜØõ	
ñ
 �TÐ$˜VÑ$Ð$r   z
    z_(...)

    .. warning::
        This method is now deprecated in favor of :func:`torch.nn.init.z"`.

    See :func:`~torch.nn.init.z` for details.éÿÿÿÿ)Ú__name__Ú__doc__)rí   r÷   rõ   rö   s   f @@r   Ú_make_deprecaterü   ý  sa   ú€ Ø�}‰}€HØ˜˜ˆ}€H÷%ò %ð$Ø€Jð Hð IQÀzð Rà'˜j¨ð:€OÔð  (€OÔØÐr   )r   r   r'   r‰   rŒ   r�   r’   r›   rª   r»   r¿   rË   rÐ   rá   rë   ÚuniformÚnormalÚconstantr™   ÚdiracÚxavier_uniformÚxavier_normalÚkaiming_uniformÚkaiming_normalÚ
orthogonalÚsparse)rs   rt   ru   rv   rw   rx   ry   rm   rn   ro   rp   rr   )r³   r´   r]   )r¾   r1   N)r¾   r1   g       Àr2   N)é   )r1   N)é    r³   rp   N)r  N)rq   N)3rû   r3   r=   Úcollections.abcr   Útypingr   r   Útyping_extensionsr   r   r   Ú__all__r   r	   rj   rÁ   r    r)   rW   r`   rf   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   Ú<module>r     sG  ðÙ Nã Û Ý $ß #Ý 'ã Ý ò€ñ> ˆTƒ]€Ùˆtƒ_€àðõÐ ð Ð&Õ'€÷:÷>÷JõZ!õ
÷
GE÷T6÷6:÷6!PõH'õ$
'õ
"õ÷*5õp÷*7÷B9õ>3÷>C÷B2;÷j0÷f&õTñ. ˜(Ó
#€Ù	˜Ó	!€Ù˜9Ó%€Ù�dÓ€Ù˜Ó€Ù  Ó1€Ù Ó/€Ù!Ð"2Ó3€Ù  Ó1€Ù˜[Ó)€
Ù	˜Ó	!‚r   