ó
    "Eñi`o  ã            &       óø  • S SK JrJr  S SKrS SKJr  SSKJrJrJrJ	r	J
r
JrJrJr  SS/r " S S\5      rS	S
\	 S\ 3-   S-   \l        S\\   S\\   S\\S-     S\\S-     S\\S-     S\\   S\S-  S\S-  S\S\\-  S\S\S\S-  S\S\S\SS4"S jrS\S\\\R.                  S-  \R0                  S-  \4   \\\S-        4   4S  jrS\\   S\\   S\\S-     S\\S-     S\\S-     S\\   S\S-  S\S-  S\S\\-  S\S\S\S-  S\S\S\SS4"S! jr\" \S"9    S%S\\   S\\   S\\S-     S\\S-     S\\S-     S\\   S#\S-  S\S-  S\S-  S\S\S\\-  S\S\S\S\S\SS4$S$ jj5       rg)&é    )ÚcastÚTYPE_CHECKINGN)ÚTensoré   )Ú_disable_dynamo_if_unsupportedÚ_get_scalar_dtypeÚ_maximize_docÚ_params_docÚ
_to_scalarÚ	OptimizerÚParamsTÚTensorListListÚ	AdafactorÚ	adafactorc                   óÐ   ^ • \ rS rSr     SSSS.S\S\\-  S\S\\S-  \4   S	\S
\S\S-  S\SS4U 4S jjjjr	U 4S jr
S\4S jr\R                  " 5       SS j5       rSrU =r$ )r   é   NF)ÚforeachÚmaximizeÚparamsÚlrÚbeta2_decayÚepsÚdÚweight_decayr   r   Úreturnc                ó´  >• [        U[        5      (       a  UR                  5       S:w  a  [        S5      eSU::  d  [        SU 35      eSU:¼  d  [        SU 35      eUS   b  SUS   ::  d  [        SUS    35      eSUS   ::  d  [        SUS    35      eS	U::  d  [        S
U 35      eSU::  d  [        SU 35      eUUUUUUUS.n	[        T
U ]  X5        g )Nr   zTensor lr must be 1-elementç        z%Learning rate should be >= 0 but is: z#beta2_decay should be <= 0 but is: r   z epsilon1 should be >= 0 but is: z epsilon2 should be >= 0 but is: ç      ð?z,Clipping threshold d should be >= 1 but is: z$weight_decay should be >= 0 but is: )r   r   r   r   r   r   r   )Ú
isinstancer   ÚnumelÚ
ValueErrorÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   ÚdefaultsÚ	__class__s             €ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/optim/_adafactor.pyr#   ÚAdafactor.__init__   s  ø€ ô �bœ&×!Ñ! b§h¡h£j°A£oÜÐ:Ó;Ð;Ø�b‹yÜÐDÀRÀDÐIÓJÐJØ�kÓ!ÜÐBÀ;À-ÐPÓQÐQØˆq‰6Ñ c¨S°©V£mÜÐ?ÀÀAÁ¸xÐHÓIÐIØ�c˜!‘f‹}ÜÐ?ÀÀAÁ¸xÐHÓIÐIØ�a‹xÜÐKÈAÈ3ÐOÓPÐPØ�lÓ"ÜÐCÀLÀ>ÐRÓSÐSàØ&ØØØ(ØØ ñ
ˆô 	‰Ñ˜Õ*ó    c                 ó|  >• [         TU ]  U5        U R                   Hœ  nUR                  SS 5        US    H~  nU R                  R                  U/ 5      n[        U5      S:w  d  M0  [        R                  " US   5      (       a  MP  [        US   5      n[        R                  " U[        5       S9US'   M€     Mž     g )Nr   r   r   Ústep©Údtype)r"   Ú__setstate__Úparam_groupsÚ
setdefaultÚstateÚgetÚlenÚtorchÚ	is_tensorÚfloatÚtensorr   )r$   r1   ÚgroupÚpÚp_stateÚstep_valr&   s         €r'   r.   ÚAdafactor.__setstate__=   s–   ø€ Ü‰Ñ˜UÔ#Ø×&Ô&ˆEØ×Ñ˜Y¨Ô-Ø˜8”_�ØŸ*™*Ÿ.™.¨¨BÓ/�Ü�w“< 1Õ$¬U¯_ª_¸WÀV¹_×-MÓ-MÜ$ W¨V¡_Ó5�HÜ&+§l¢l°8ÔCTÓCVÑ&W�G˜F“Oó	 %ò 'r)   c                 ó>  • US    GH  nUR                   c  M  [        R                  " U5      (       a  [        S5      eUR                   R                  (       a  [        S5      eUR                  U5        UR                  UR                   5        U R                  U   n	[        U	5      S:X  aó  [        R                  " S[        5       S9U	S'   UR                   R                  5       S:”  a…  [        UR                   R                  5      n
SU
S	'   UR                   R                  U
5      U	S
'   [        UR                   R                  5      nSUS'   UR                   R                  U5      U	S'   O0[        R                  " UR                   [        R                  S9U	S'   UR                  U	R!                  S
S 5      5        UR                  U	R!                  SS 5      5        UR                  U	R!                  SS 5      5        UR                  U	S   5        GM     g)Nr   z-Adafactor does not support complex parametersz+Adafactor does not support sparse gradientsr   r   r,   r+   r   éÿÿÿÿÚrow_varéþÿÿÿÚcol_var)Úmemory_formatÚvarianceF)Úgradr4   Ú
is_complexÚRuntimeErrorÚ	is_sparseÚappendr1   r3   r7   r   ÚdimÚlistÚshapeÚ	new_zerosÚ
zeros_likeÚpreserve_formatr2   )r$   r8   Úparams_with_gradÚgradsÚrow_varsÚcol_varsÚ	variancesÚstate_stepsr9   r1   Ú	row_shapeÚ	col_shapes               r'   Ú_init_groupÚAdafactor._init_groupG   s¦  € ð �x•ˆAØ�v‰v‰~ÙÜ×Ò ×"Ñ"Ü"Ð#RÓSÐSØ�v‰v××Ü"Ð#PÓQÐQà×#Ñ# AÔ&Ø�L‰L˜Ÿ™Ô à—J‘J˜q‘MˆEô �5‹z˜Q‹ô !&§¢¨SÔ8IÓ8KÑ L��f‘à—6‘6—:‘:“< !Ó#Ü $ Q§V¡V§\¡\Ó 2�IØ$%�I˜b‘Mà'(§v¡v×'7Ñ'7¸	Ó'B�E˜)Ñ$ä $ Q§V¡V§\¡\Ó 2�IØ$%�I˜b‘Mà'(§v¡v×'7Ñ'7¸	Ó'B�E˜)Ò$ä(-×(8Ò(8ØŸ™¬e×.CÑ.Cñ)�E˜*Ñ%ð �O‰O˜EŸI™I i°Ó6Ô7Ø�O‰O˜EŸI™I i°Ó6Ô7Ø×Ñ˜UŸY™Y z°4Ó8Ô9Ø×Ñ˜u V™}×-ñK !ðL r)   c                 ó˜  • U R                  5         SnUb%  [        R                  " 5          U" 5       nSSS5        U R                   Hn  n/ n/ n/ n/ n/ n/ n	US   u  p«U R	                  UUUUUUU	5      n[        UUUUUU	US   US   US   US   U
UUS   US   [        U S	S5      [        U S
S5      US9  Mp     U$ ! , (       d  f       NŽ= f)z�Perform a single optimization step.

Args:
    closure (Callable, optional): A closure that reevaluates the model
        and returns the loss.
Nr   r   r   r   r   r   r   Ú
grad_scaleÚ	found_inf)r   r   r   r   Úeps1Úeps2r   r   rZ   r[   Úhas_complex)Ú'_accelerator_graph_capture_health_checkr4   Úenable_gradr/   rW   r   Úgetattr)r$   ÚclosureÚlossr8   rO   rP   rQ   rR   rS   rT   r\   r]   r^   s                r'   r+   ÚAdafactor.stepy   s  € ð 	×4Ñ4Ô6àˆØÑÜ×"Ò"Õ$Ù“y�÷ %ð ×&Ô&ˆEØ-/ÐØ"$ˆEØ,.ˆHØ,.ˆHØ-/ˆIØ(*ˆKØ˜u™‰JˆDà×*Ñ*ØØ ØØØØØóˆKô Ø ØØØØØØ˜‘*Ø˜‘;Ø! -Ñ0Ø" >Ñ2ØØØ˜iÑ(Ø˜zÑ*Ü" 4¨°tÓ<Ü! $¨°TÓ:Ø'ô#ñ' 'ðN ˆ÷U %Õ$ús   «B;Â;
C	© )g{®Gáz„?gš™™™™™é¿)Ngü©ñÒMbP?r   r   ©N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r6   r   ÚtupleÚboolr#   r.   rW   r4   Úno_gradr+   Ú__static_attributes__Ú__classcell__)r&   s   @r'   r   r      sÊ   ø† ð "Ø!Ø*6ØØ!ð#+ð  $Øò#+àð#+ð �F‰Nð#+ð ð	#+ð
 �5˜4‘< Ð&Ñ'ð#+ð ð#+ð ð#+ð ˜‘ð#+ð ð#+ð 
÷#+ñ #+õJXð0ð 
ô0ðd ‡]‚]ƒ_ó5ó ö5r)   a‚  Implements Adafactor algorithm.

    .. math::
        \begin{aligned}
            &\rule{110mm}{0.4pt}                                                                 \\
            &\textbf{input}      : \gamma \text{(lr)}, \: \tau
                \text{(}\beta_2\text{ decay)}, \: \theta_0 \text{(params)}, \: f(\theta) \text{(objective)},    \\
            &\hspace{15mm}      \: \epsilon_1, \epsilon_2 \text{ (epsilons)}, \: d \text{(clipping threshold)}, \\
            &\hspace{15mm}      \: \lambda \text{(weight decay)},
                \: \textit{maximize}                                                             \\
            &\textbf{initialize} : \: R_0 \leftarrow 0 \text{ (second moment row factor)},       \\
            &\hspace{23mm} \: C_0 \leftarrow 0 \text{ (second moment col factor)},               \\
            &\hspace{23mm} \: \widehat{V}_0 \leftarrow 0 \text{ (second moment for vectors)}     \\[-1.ex]
            &\rule{110mm}{0.4pt}                                                                 \\
            &\textbf{for} \: t=1 \: \textbf{to} \: \ldots \: \textbf{do}                         \\

            &\hspace{5mm}\textbf{if} \: \textit{maximize}:                                       \\
            &\hspace{10mm}G_t           \leftarrow   -\nabla_{\theta} f_t (\theta_{t-1})         \\
            &\hspace{5mm}\textbf{else}                                                           \\
            &\hspace{10mm}G_t           \leftarrow   \nabla_{\theta} f_t (\theta_{t-1})          \\
            &\hspace{5mm}\widehat{\beta}_{2_t} \leftarrow 1 - t^{\tau}                           \\
            &\hspace{5mm}\rho_t         \leftarrow min(lr, \frac{1}{\sqrt{t}})                   \\
            &\hspace{5mm}\alpha_t       \leftarrow max(\epsilon_2,
                \text{RMS}(\theta_{t-1}))\rho_t                                                  \\
            &\hspace{5mm}\theta_t       \leftarrow \theta_{t-1} - \gamma \lambda \theta_{t-1}    \\
            &\hspace{5mm}\textbf{if} \: \text{dim}(G_t) > 1:                                     \\
            &\hspace{10mm}R_t           \leftarrow \widehat{\beta}_{2_t}R_{t-1}+
                (1-\widehat{\beta}_{2_t})(G_t \odot G_t) \cdot 1_m                               \\
            &\hspace{10mm}C_t           \leftarrow \widehat{\beta}_{2_t}C_{t-1}+
                (1-\widehat{\beta}_{2_t}) 1^\top_n \cdot (G_t \odot G_t)                         \\
            &\hspace{10mm}\widehat{V}_t \leftarrow
                \frac{R_t \cdot C_t}{max(1^\top_n \cdot R_t, \epsilon_1)}                        \\
            &\hspace{5mm}\textbf{else}                                                           \\
            &\hspace{10mm}\widehat{V}_t \leftarrow \widehat{\beta}_{2_t}\widehat{V}_{t-1}+
                (1-\widehat{\beta}_{2_t}) \cdot (G_t \odot G_t)                                  \\
            &\hspace{5mm}U_t            \leftarrow
                \frac{G_t}{max(\sqrt{\widehat{V}_t}, \epsilon_1)}                                \\
            &\hspace{5mm}\widehat{U}_t  \leftarrow \frac{U_t}{max(1, \frac{\text{RMS}(U_t)}{d})} \\
            &\hspace{5mm}\theta_t       \leftarrow \theta_{t-1} - \alpha_t \widehat{U}_t         \\

            &\rule{110mm}{0.4pt}                                                          \\[-1.ex]
            &\bf{return} \:  \theta_t                                                     \\[-1.ex]
            &\rule{110mm}{0.4pt}                                                          \\[-1.ex]
        \end{aligned}

    For further details regarding the algorithm we refer to `Adafactor: Adaptive Learning Rates with Sublinear Memory Cost`_.
    z
    Args:
        a·  
        lr (float, Tensor, optional): unlike other optimizers, Adafactor does not require a
            learning rate, and Noam Shazeer and Mitchell Stern do not use lr at all.
            Deviating from the paper, this implementation uses lr for applying weight
            decay and as the maximum value for relative step size rho_t. Note that in
            the paper, a constant of 0.01 is used as the maximum value for relative
            step size, and so we set 0.01 as the default value. (default: 1e-2)
        beta2_decay (float, optional): the decay rate of beta2. beta2 standardly refers
            to the coefficient used for computing the running average of the gradient
            squared. (default: -0.8)
        eps (Tuple[float, float], optional): epsilon1 is the term added to the denominator
            of the update calculation to improve numerical stability. This use of epsilon1
            deviates from the algorithm written in the paper! See note below for more details.
            epsilon2 is the term used to avoid having too small a weight update when applying
            parameter scaling. (default: (None, 1e-3))
        d (float, optional): the clipping threshold, used to avoid larger-than-desired
            updates.
        weight_decay (float, optional): weight decay coefficient (default: 1e-2)
        foreach (bool, optional): whether foreach implementation of optimizer is used. Note
            that the foreach implementation uses ~ sizeof(params) more peak memory than the
            for-loop version due to the intermediates being a tensorlist vs just one tensor.
            As Adafactor is commonly used when memory is prohibitive, Adafactor will default
            to the slower single tensor for-loop implementation unless this flag is explicitly
            True. This behavior is contrary to other optimizers, which will attempt defaulting
            to foreach on CUDA for faster runtime. (default: None)
        a4  
    .. Note::
        The implementation of Adafactor subtly differs from Noam Shazeer and Mitchell Stern
        and implementations in some other frameworks with its use of learning rate and
        :math:`\epsilon_1`.

        Regarding the learning rate hyperparameter: Noam Shazeer and Mitchell Stern do not
        use lr at all, as the stated algorithm uses :math:`\rho_t` and update clipping to
        affect the step size.

        This implementation allows `lr` to influence the maximum value for :math:`\rho_t`:

        .. math::
            \begin{aligned}
                &\hspace{5mm}\rho_t \leftarrow min(lr, \frac{1}{\sqrt{t}})
            \end{aligned}

        This differs from Noam Shazeer and Mitchell Stern, who use a constant of 0.01 as
        the maximum value of :math:`\rho_t`

        .. math::
            \begin{aligned}
                &\hspace{5mm}\rho_t \leftarrow min(0.01, \frac{1}{\sqrt{t}})
            \end{aligned}

        Noam Shazeer and Mitchell Stern do not enforce an opinion on how weight decay should
        be computed, and so we use the learning rate as a coefficient for decoupled weight
        decay, similar to what is suggested in `Decoupled Weight Decay Regularization`_.

        Regarding the use of :math:`\epsilon_1`: The implementation attempts to replicate the
        presumed intention of Noam Shazeer and Mitchell Stern to use :math:`\epsilon_1` as
        a stabilizing term when the squared gradient becomes small.

        This stabilization can be written as

        .. math::
            \begin{aligned}
                &\hspace{5mm}R_t \leftarrow \widehat{\beta}_{2_t}R_{t-1}+
                    (1-\widehat{\beta}_{2_t})(G_t \odot G_t + 1_n \cdot 1^\top_m) \cdot 1_m          \\
                &\hspace{5mm}C_t \leftarrow \widehat{\beta}_{2_t}C_{t-1}+
                    (1-\widehat{\beta}_{2_t}) 1^\top_n \cdot (G_t \odot G_t + 1_n \cdot 1^\top_m)    \\
                &\hspace{5mm}\widehat{V}_t \leftarrow
                    \frac{R_t \cdot C_t}{max(1^\top_n \cdot R_t, \epsilon_1)}                        \\
                &\hspace{5mm}U_t \leftarrow \frac{G_t}{max(\sqrt{\widehat{V}_t}, \epsilon_1)}        \\
            \end{aligned}

        where the row and column factors of gradient squared :math:`R_t` and :math:`C_t`
        are left alone, and we apply :math:`\epsilon_1` at the final calculation of
        the variance estimate :math:`\widehat{V}_t` and for the update :math:`U_t`.

        This is in contrast to Noam Shazeer and Mitchell Stern and other frameworks which
        apply :math:`\epsilon_1` to both row and column factors of the squared gradient, but
        not in the calculations after:

        .. math::
            \begin{aligned}
                &\hspace{5mm}R_t \leftarrow \widehat{\beta}_{2_t}R_{t-1}+
                            (1-\widehat{\beta}_{2_t})(G_t \odot G_t + \epsilon_1 1_n \cdot 1^\top_m) \cdot 1_m          \\
                &\hspace{5mm}C_t \leftarrow \widehat{\beta}_{2_t}C_{t-1}+
                            (1-\widehat{\beta}_{2_t}) 1^\top_n \cdot (G_t \odot G_t + \epsilon_1 1_n \cdot 1^\top_m)    \\
                &\hspace{5mm}\widehat{V}_t \leftarrow \frac{R_t \cdot C_t}{1^\top_n \cdot R_t}                          \\
                &\hspace{5mm}U_t \leftarrow \frac{G_t}{\sqrt{\widehat{V}_t}}                                            \\
            \end{aligned}

        You may note that Noam Shazeer and Mitchell Stern describe using the sum of squared gradients,
        while this implementation uses the mean instead. This choice is mathematically equivalent and
        allows for greater numerical stability for large sums.

    .. _Adafactor\: Adaptive Learning Rates with Sublinear Memory Cost:
        https://arxiv.org/pdf/1804.04235
    .. _Decoupled Weight Decay Regularization:
        https://arxiv.org/abs/1711.05101
    r   rP   rQ   rR   rS   rT   rZ   r[   r   r   r   r   r\   r]   r   r^   r   c                ó0  • Uc  Ub  [        S5      e[        R                  R                  5       (       a-  [	        U	[
        5      (       d  [        S[        U	5       35      eO[        U	5      n	[        U 5       GHš  u  nnU(       d  UU   OUU   * nUU   nUU   nUU   nUU   nUc*  [        R                  " UR                  5      R                  nUS-  nUR                  5       nUU
-  n[        U	SUS-  -  5      n[        UUR                  S5      R                  5       UR!                  5       S-  -  5      U-  nUS:w  a  UR#                  SX›-  -
  5        UR%                  5       S:”  aë  Ub  Uc  [        S5      e[        R                  " USS	S
9R'                  5       R)                  UR+                  S5      5      nUR-                  UU5        [        R                  " USS	S
9R'                  5       R)                  UR+                  S5      5      nUR-                  UU5        UU-  nUR)                  UR/                  SS	S
9R1                  US95        O5Uc  [        S5      eUU-  nUR-                  UU5        UR3                  5       nUR1                  XÌ-  S9R5                  5       nUR#                  U5        [        SUR                  S5      R                  5       UR!                  5       S-  U-  -  5      n UR7                  UU* U -  S9  GM�     g )Nú5Grad scaling should occur outside of optimizer.step()z#Expected lr to be a float, but got r   ç      à?é   r   úCrow_var and col_var should be defined when grad is multidimensionalr>   T©rI   Úkeepdimr@   )Úminú0variance should be defined when grad is a vectorr   ©Úalpha)ÚAssertionErrorr4   ÚjitÚis_scriptingr   r6   Útyper   Ú	enumerateÚfinfor-   r   Úitemrw   ÚmaxÚnormr    Úmul_rI   Úsquare_Údiv_ÚsizeÚlerp_ÚmeanÚclamp_ÚcloneÚrsqrt_Úadd_)!r   rP   rQ   rR   rS   rT   rZ   r[   r   r   r   r   r\   r]   r   r^   ÚiÚparamrD   Ústep_tr?   rA   rC   Ú
step_floatÚone_minus_beta2_tÚrho_trz   Úrow_meanÚcol_meanÚvar_estimateÚgrad_squaredÚupdateÚdenoms!                                    r'   Ú_single_tensor_adafactorrš   J  sß  € ð. Ñ Ñ!6ÜÐTÓUÐUä‡y�y×Ñ×Ñô ˜"œe×$Ñ$Ü Ð#FÄtÈBÃxÀjÐ!QÓRÐRð %ô ˜‹^ˆä˜f×%‰ˆˆ5Þ'ˆu�QŠx¨e°A©h¨YˆØ˜Q‘ˆØ˜1‘+ˆØ˜1‘+ˆØ˜Q‘<ˆØ‰<Ü—;’;˜uŸ{™{Ó+×/Ñ/ˆDð 	�!‰ˆØ—[‘[“]ˆ
à&¨Ñ3ÐÜ�B˜˜Z¨™_Ñ-Ó.ˆÜ�D˜%Ÿ*™* Q›-×,Ñ,Ó.°%·+±+³-À3Ñ2FÑGÓHÈ5ÑPˆð ˜1ÓØ�J‰J�q˜2Ñ,Ñ,Ô-à�8‰8‹:˜‹>Ø‰ '¡/Ü$ØYóð ô
 —
’
˜4 R°Ñ6×>Ñ>Ó@×EÑEÀdÇiÁiÐPRÃmÓTð ð �M‰M˜(Ð$5Ô6ô —
’
˜4 R°Ñ6×>Ñ>Ó@×EÑEÀdÇiÁiÐPRÃmÓTð ð �M‰M˜(Ð$5Ô6Ø" WÑ,ˆLØ×Ñ˜gŸl™l¨r¸4˜lÐ@×GÑGÈDÐGÐQÕRàÑÜ$Ð%WÓXÐXØ $™;ˆLØ�N‰N˜<Ð):Ô;à#Ÿ>™>Ó+ˆLð ×$Ñ$¨©Ð$Ð5×<Ñ<Ó>ˆØ�‰�DÔÜ�C˜Ÿ™ Q›×,Ñ,Ó.°6·<±<³>ÀSÑ3HÈAÑ2MÑNÓOˆØ�
‰
�6 % ¨%¡ˆ
Ô0òe &r)   Útensorlistsc                 óL  • [         R                  " U 5      n0 nUR                  5        Hí  u  u  p4u  pX4S4nX4S4n[        U S   5       HÉ  u  p‰U	c  [	        S5      eU	R                  5       S:”  aR  Xb;  a  U  Vs/ s H  n/ PM     snX&'   [        [        U 5      5       H  n
X&   U
   R                  X
   U   5        M      My  Xr;  a  U  Vs/ s H  n/ PM     snX''   [        [        U 5      5       H  n
X'   U
   R                  X
   U   5        M      MË     Mï     U$ s  snf s  snf )zîGroups tensors by device, dtype, AND multidimensionality -- whether the tensor
has multiple dims or just one dim (is a vector). This allows the foreach impl of
Adafactor to assume that every group of params will either be factored or not.TFr   zgrad should not be None)	r   Ú"_group_tensors_by_device_and_dtypeÚitemsr   r{   rI   Úranger3   rH   )r›   Úgrouped_tensorsÚultra_grouped_tensorsÚdevicer-   Ú_Ú
matrix_keyÚ
vector_keyÚjr7   rŽ   s              r'   Ú._group_tensors_by_device_dtype_and_is_multidimr§   £  s<  € ô  ×BÒBÀ;ÓO€Oð 	ð ð .=×-BÑ-BÖ-DÑ)‰ˆÑ)˜+Ø TÐ*ˆ
Ø UÐ+ˆ
ô # ;¨q¡>Ö2‰IˆAØ‰~Ü$Ð%>Ó?Ð?Ø�z‰z‹|˜aÓØÓ:ÙEPÓ8QÂ[À»Á[Ñ8QÐ)Ñ5Üœs ;Ó/Ö0�AØ)Ñ5°aÑ8×?Ñ?ÀÁÈqÑ@QÖRó 1ð Ó:ÙEPÓ8QÂ[À»Á[Ñ8QÐ)Ñ5Üœs ;Ó/Ö0�AØ)Ñ5°aÑ8×?Ñ?ÀÁÈqÑ@QÖRó 1ó 3ñ .Eð$ !Ð ùò 9Rùò
 9Rs   Á9DÃD!c                óÀ  • [        U 5      S:X  a  g Uc  Ub  [        S5      e[        U	5      n	[        XX#XE/5      nUR	                  5        GH_  u  u  nnnu  nnnnnn[        [        [           U5      n[        [        [           U5      n[        [        [           U5      nUc.  Uc  [        S5      e[        R                  " U5      R                  n[        (       a  US   c   eU(       a  [        R                  " U5      n[        R                  R                  5       (       d>  US   R                  (       a*  [        R                   " U[        R"                  " SSS9SS9  O[        R                   " US5        / n/ n/ nU Hy  n UR%                  U R'                  5       U
-  5        UR%                  SU R'                  5       U
-  -
  5        UR%                  [)        U	SU R'                  5       S	-  -  5      5        M{     [+        UUS
S9 V!V"s/ s HF  u  n!n"[-        UU!R/                  S5      R'                  5       U!R1                  5       S	-  -  5      U"-  PMH     n#n!n"US:w  a  [        R2                  " USX›-  -
  5        U(       GaÒ  [        [        [           U5      n$[        [        [           U5      n%U$S   b  U%S   c  [        S5      eU V&s/ s H  n&[        R.                  " U&SS
S9PM     n'n&[        R2                  " U'U'5        [        R4                  " U'U V&s/ s H  n&U&R7                  S5      PM     sn&5        [        R8                  " U$U'U5        A'U V&s/ s H  n&[        R.                  " U&SS
S9PM     n(n&[        R2                  " U(U(5        [        R4                  " U(U V&s/ s H  n&U&R7                  S5      PM     sn&5        [        R8                  " U%U(U5        A([+        U$U%S
S9 V)V*s/ s H  u  n)n*U)U*-  PM     n+n)n*U$ V)s/ s H  n)U)R;                  SS
S9PM     n,n)[        R<                  " U,U5        [        R4                  " U+U,5        A,Ox[        [        [           U5      n-U-S   c  [        S5      e[        R>                  " UU5      n.[        R8                  " U-U.U5        A.U- V/s/ s H  n/U/RA                  5       PM     n+n/[        R<                  " U+XÌ-  5        [        RB                  " U+5        [        R2                  " U+U5        U+n0[+        U#U0S
S9 V1V2s/ s HJ  u  n1n2U1* [-        SU2R/                  S5      R'                  5       U2R1                  5       S	-  U-  -  5      -  PML     n#n1n2[        R2                  " U0U#5        [        R                   " UU05        GMb     g s  sn"n!f s  sn&f s  sn&f s  sn&f s  sn&f s  sn*n)f s  sn)f s  sn/f s  sn2n1f )Nr   rq   z2dtype is needed to compute eps1 when eps1 is unsetr   Úcpu)r¢   ry   r   rr   T)Ústrictrs   rt   r>   ru   r@   rx   )"r3   r{   r   r§   rž   r   rJ   r   r4   r€   r   r   Ú_foreach_negÚcompilerÚis_compilingÚis_cpuÚ_foreach_add_r7   rH   r�   rw   Úzipr‚   rƒ   r    Ú_foreach_mul_Ú_foreach_div_r‡   Ú_foreach_lerp_r‰   Ú_foreach_clamp_min_Ú_foreach_mulr‹   Ú_foreach_rsqrt_)3r   rP   rQ   rR   rS   rT   rZ   r[   r   r   r   r   r\   r]   r   r^   r    r£   r-   Úis_multidimÚdevice_params_Údevice_grads_Údevice_row_vars_Údevice_col_vars_Údevice_variances_Údevice_state_steps_Údevice_paramsÚdevice_gradsÚdevice_state_stepsÚone_minus_beta2_tsÚbeta2_tsÚrho_tsÚsr9   ÚrÚalphasÚdevice_row_varsÚdevice_col_varsrD   Ú	row_meansÚ	col_meansr?   rA   Úvar_estimatesÚrow_var_meansÚdevice_variancesÚgrads_squaredÚvÚupdatesÚar˜   s3                                                      r'   Ú_multi_tensor_adafactorrÒ   Æ  s~  € ô. ˆ6ƒ{�aÓØàÑ Ñ!6ÜÐTÓUÐUä	�B‹€BäDØ	˜¨IÐCó€Oð 
×	Ñ	×	 ñ		ÑˆˆE�;ñ	
ØØØØØØô œT¤&™\¨>Ó:ˆÜœD¤™L¨-Ó8ˆÜ!¤$¤v¡,Ð0CÓDÐØ‰<Ø‰}Ü$ØHóð ô —;’;˜uÓ%×)Ñ)ˆDçŠ=Ø% aÑ(Ñ4Ð4Ð4æÜ ×-Ò-¨lÓ;ˆLô �~‰~×*Ñ*×,Ñ,Ð1CÀAÑ1F×1M×1MÜ×ÒØ"¤E§L¢L°¸UÑ$CÈ3óô ×ÒÐ 2°CÔ8àÐØˆØˆÛ#ˆAØ×%Ñ% a§f¡f£h°+Ñ&=Ô>Ø�O‰O˜A §¡£¨KÑ 7Ñ7Ô8Ø�M‰Mœ#˜b ! q§v¡v£x°3¡Ñ"7Ó8Ö9ñ $ô ˜M¨6¸$Ò?ô
â?‘��1ô ��a—f‘f˜Q“i—n‘nÓ&¨!¯'©'«)°sÑ*:Ñ;Ó<¸qÔ@Ù?ð 	ñ 
ð ˜1ÓÜ×Ò ¨q°2Ñ3DÑ/DÔEçÜ"¤4¬¡<Ð1AÓBˆOÜ"¤4¬¡<Ð1AÓBˆOØ˜qÑ!Ñ)¨_¸QÑ-?Ñ-GÜ$ØYóð ñ
 DPóÚCO¸4”—
’
˜4 R°Ô6Á<ð ð ô ×Ò 	¨9Ô5Ü×Ò 	ÁlÓ+SÂl¸d¨D¯I©I°b®MÁlÑ+SÔTÜ× Ò  °)Ð=OÔPØñ DPóÚCO¸4”—
’
˜4 R°Ô6Á<ð ð ô ×Ò 	¨9Ô5Ü×Ò 	ÁlÓ+SÂl¸d¨D¯I©I°b®MÁlÑ+SÔTÜ× Ò  °)Ð=OÔPØô ),Ø# _¸Tò)ôò)Ñ$�G˜Wð ˜'Ô!ñ)ð ñ ñ CRóÚBQ°w�—‘ ¨T�Ó2Á/ð ð ô ×%Ò% m°TÔ:Ü×Ò ¨}Ô=Ùä#¤D¬¡LÐ2CÓDÐØ Ñ"Ñ*Ü$Ð%WÓXÐXä!×.Ò.¨|¸\ÓJˆMÜ× Ò Ð!1°=ÐBTÔUØñ 1AÓAÒ0@¨1˜QŸW™WžYÑ0@ˆMÐAô 	×!Ò! -°±Ô=Ü×Ò˜mÔ,Ü×Ò˜M¨<Ô8Øˆô ! ¨¸Ò>ô
â>‘	��6ð ˆB”#�c˜6Ÿ;™; q›>×.Ñ.Ó0°V·\±\³^ÀsÑ5JÈaÑ4OÑPÓQÔRÙ>ð 	ñ 
ô 	×Ò˜G VÔ,Ü×Ò˜M¨7×3òS 
!ùóH
ùò"ùò ,Tùò
ùò ,Tùóùòùò  Bùó
s8   ÈAV0Ë V6ÌV;Í W Î,WÏ5W
ÐWÒ6WÔ(AW)Úsingle_tensor_fnr   c
                óà   • [         R                  R                  5       (       d"  [        S U 5       5      (       d  [	        S5      eU(       a  [
        nO[        nU" U UUUUUU
UUUUUUUUU	S9  g)zpFunctional API that performs Adafactor algorithm computation.

See :class:`~torch.optim.Adafactor` for details.
c              3   óV   #   • U  H  n[        U[        R                  5      v •  M!     g 7frf   )r   r4   r   )Ú.0Úts     r'   Ú	<genexpr>Úadafactor.<locals>.<genexpr>x  s!   é € ð 5Ú-8¨Œ
�1”e—l‘l×#Ð#ª[ùs   ‚')z?`state_steps` argument must contain a list of singleton tensors)
r   r   r   r   r\   r]   r   rZ   r[   r^   N)r4   r¬   r­   ÚallrF   rÒ   rš   )r   rP   rQ   rR   rS   rT   r   rZ   r[   r^   r   r   r   r   r\   r]   r   Úfuncs                     r'   r   r   ]  s‰   € ô6 �>‰>×&Ñ&×(Ñ(´ñ 5Ù-8ó5÷ 2ñ 2ô ØMó
ð 	
ö Ü&‰ä'ˆáØØØØØØØ
ØØØ!ØØØØØØó!r)   )NNNF)Útypingr   r   r4   r   Ú	optimizerr   r   r	   r
   r   r   r   r   Ú__all__r   Ú__doc__rJ   r6   rl   rš   Údictrk   r¢   r-   r§   rÒ   r   re   r)   r'   Ú<module>rá      sÅ  ð÷ 'ã Ý ÷	÷ 	ó 	ð ˜Ð
$€ôX�	ô Xðx.ð^	à	ˆð 	ð2 
ˆð7ñ_JðVHñWSð 
Ô ðpV1Ø�‰LðV1à�‰<ðV1ð �6˜D‘=Ñ!ðV1ð �6˜D‘=Ñ!ðV1ð �F˜T‘MÑ"ðV1ð �f‘ðV1ð ˜‘ðV1ð ˜‰}ðV1ð ðV1ð 	�‰ðV1ð  ð!V1ð" ð#V1ð$ �$‰,ð%V1ð& ð'V1ð( ð)V1ð* ð+V1ð, 
ô-V1ðr !Øð !à	Ø	ˆ%�,‰,˜Ñ
˜uŸ{™{¨TÑ1°4Ð
7Ñ8Øˆˆf�t‰mÑ	Ñðñô !ðFT4Ø�‰LðT4à�‰<ðT4ð �6˜D‘=Ñ!ðT4ð �6˜D‘=Ñ!ðT4ð �F˜T‘MÑ"ðT4ð �f‘ðT4ð ˜‘ðT4ð ˜‰}ðT4ð ðT4ð 	�‰ðT4ð  ð!T4ð" ð#T4ð$ �$‰,ð%T4ð& ð'T4ð( ð)T4ð* ð+T4ð, 
ô-T4ñn  Ð1IÑJð  Ø $Ø#Øñ7Ø�‰Lð7à�‰<ð7ð �6˜D‘=Ñ!ð7ð �6˜D‘=Ñ!ð	7ð
 �F˜T‘MÑ"ð7ð �f‘ð7ð �D‰[ð7ð ˜‘ð7ð ˜‰}ð7ð ð7ð ð7ð 	�‰ð7ð  ð!7ð" ð#7ð$ ð%7ð& ð'7ð( ð)7ð* 
ô+7ó Kñ7r)   