+
    QV-jïÖ  ã                  ó~  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RI	t	^ RI
Ht ^ RIHtHt ^RIHtHt ^RIHt ^R	IHt ]P,                  ! ]4      tRBR
 ltRCR R lltR R ltR R ltRCR R lltR R ltRCR ltR R lt RDR R llt!R R lt"RER R llt#R R lt$RFR  lt%R!R/R" R# llt&RGR$ R% llt'R&R'/R( R) llt RHR* R+ llt(R&R'R,R/R- R. llt)RIR/ R0 llt*R1 R2 lt+RJR3 R4 llt, ! R5 R64      t- ! R7 R84      t.R9 R: lt/]P`                  ]]Pb                  ]!]Pd                  ]#]Pf                  ]%]Ph                  ]]Pj                  ]]Pl                  ]']Pn                  ]]Pp                  ](]Pr                  ]*]Pt                  ],]Pv                  ]//t<RKR; R< llt= ! R= R>]4      t> ! R? R@]4      t?RLRA lt@R# )Mz$PyTorch optimization for BERT model.)ÚannotationsN)Úpartial)ÚAny)Ú	Optimizer)ÚLambdaLRÚReduceLROnPlateau)ÚLayerWiseDummyOptimizerÚLayerWiseDummyScheduler)ÚSchedulerType)Úloggingc                ó   € ^# ©é   © )Ú_s   &Új/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/optimization.pyÚ_get_constant_lambdar   #   s   € Ùó    c               ó    € V ^8„  d   QhRRRR/# )é   Ú	optimizerr   Ú
last_epochÚintr   )Úformats   "r   Ú__annotate__r   '   s   € ÷ Lñ L Yð L¸Cñ Lr   c                ó&   € \        V \        VR7      # )aŽ  
Create a schedule with a constant learning rate, using the learning rate set in optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
©r   )r   r   )r   r   s   &&r   Úget_constant_scheduler   '   s   € ô �IÔ3À
ÔKÐKr   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   r   8   s   € ÷ 2ñ 2¨iñ 2r   c                ó   € \        V 3/ VB # )aÛ  
Create a schedule with a constant learning rate that decreases when a metric has stopped improving.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    kwargs (`dict`, *optional*):
        Extra parameters to be passed to the scheduler. See `torch.optim.lr_scheduler.ReduceLROnPlateau`
        for possible parameters.

Return:
    `torch.optim.lr_scheduler.ReduceLROnPlateau` with the appropriate schedule.
)r   ©r   Úkwargss   &,r   Úget_reduce_on_plateau_scheduler#   8   s   € ô ˜YÑ1¨&Ñ1Ð1r   c               ó    € V ^8„  d   QhRRRR/# )r   Úcurrent_stepr   Únum_warmup_stepsr   )r   s   "r   r   r   J   s   € ÷ ñ ¸sð ÐY\ñ r   c               ó\   € W8  d&   \        V 4      \        \        R V4      4      ,          # R # )ç      ð?©ÚfloatÚmax)r%   r&   s   &$r   Ú,_get_constant_schedule_with_warmup_lr_lambdar,   J   s(   € ØÔ&Ü�\Ó"¤U¬3¨sÐ4DÓ+EÓ%FÕFÐFÙr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r&   r   r   r   )r   s   "r   r   r   P   s'   € ÷ Añ A°ð AÈcð AÐ_bñ Ar   c                ó>   € \        \        VR7      p\        WVR7      # )a4  
Create a schedule with a constant learning rate preceded by a warmup period during which the learning rate
increases linearly between 0 and the initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
©r&   r   )r   r,   r   )r   r&   r   Ú	lr_lambdas   &&& r   Ú!get_constant_schedule_with_warmupr1   P   s   € ô" ÔDÐWgÔh€IÜ�I°ZÔ@Ð@r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r%   r   r&   Únum_training_stepsr   )r   s   "r   r   r   e   s(   € ÷ uñ u¸Sð uÐWZð uÐpsñ ur   c               óÎ   € W8  d&   \        V 4      \        \        ^V4      4      ,          # \        R\        W ,
          4      \        \        ^W!,
          4      4      ,          4      # )r   ç        r)   )r%   r&   r3   s   &$$r   Ú*_get_linear_schedule_with_warmup_lr_lambdar6   e   sP   € ØÔ&Ü�\Ó"¤U¬3¨qÐ2BÓ+CÓ%DÕDÐDÜˆs”EÐ,Õ;Ó<¼uÄSÈÐL^ÕLqÓErÓ?sÕsÓtÐtr   c                ó>   € \        \        VVR7      p\        WV4      # )a¥  
Create a schedule with a learning rate that decreases linearly from the initial lr set in the optimizer to 0, after
a warmup period during which it increases linearly from 0 to the initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_training_steps (`int`):
        The total number of training steps.
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
)r&   r3   )r   r6   r   )r   r&   r3   r   r0   s   &&&& r   Úget_linear_schedule_with_warmupr8   k   s&   € ô& Ü2Ø)Ø-ô€Iô
 �I¨*Ó5Ð5r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r%   r   r&   r3   Ú
num_cyclesr*   r   )r   s   "r   r   r   †   s2   € ÷ Zñ ZØðZØ,/ðZØEHðZØV[ñZr   c               ón  € W8  d&   \        V 4      \        \        ^V4      4      ,          # \        W,
          4      \        \        ^W!,
          4      4      ,          p\        RRR\        P                  ! \        P                  \        V4      ,          R,          V,          4      ,           ,          4      # )r   r5   ç      à?r(   ç       @©r*   r+   ÚmathÚcosÚpi©r%   r&   r3   r:   Úprogresss   &$$$ r   Ú*_get_cosine_schedule_with_warmup_lr_lambdarD   †   s�   € ð Ô&Ü�\Ó"¤U¬3¨qÐ2BÓ+CÓ%DÕDÐDÜ�\Õ4Ó5¼¼cÀ!ÐEWÕEjÓ>kÓ8lÕl€HÜˆs�C˜3¤§¢¬$¯'©'´E¸*Ó4EÕ*EÈÕ*KÈhÕ*VÓ!WÕWÕXÓYÐYr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r   r   r&   r   r3   r:   r*   r   r   )r   s   "r   r   r   �   s4   € ÷ 6ñ 6Øð6Ø,/ð6ØEHð6ØV[ð6Øorñ6r   c                ó@   € \        \        VVVR7      p\        WV4      # )a•  
Create a schedule with a learning rate that decreases following the values of the cosine function between the
initial lr set in the optimizer to 0, after a warmup period during which it increases linearly between 0 and the
initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_training_steps (`int`):
        The total number of training steps.
    num_cycles (`float`, *optional*, defaults to 0.5):
        The number of waves in the cosine schedule (the defaults is to just decrease from the max value to 0
        following a half-cosine).
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
©r&   r3   r:   )r   rD   r   ©r   r&   r3   r:   r   r0   s   &&&&& r   Úget_cosine_schedule_with_warmuprI   �   s)   € ô2 Ü2Ø)Ø-Øô	€Iô �I¨*Ó5Ð5r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r%   r   r&   r3   r:   r   )r   s   "r   r   r   ±   s2   € ÷ ^ñ ^Øð^Ø,/ð^ØEHð^ØVYñ^r   c               ó€  € W8  d&   \        V 4      \        \        ^V4      4      ,          # \        W,
          4      \        \        ^W!,
          4      4      ,          pVR8¼  d   R# \        RRR\        P                  ! \        P                  \        V4      V,          R,          ,          4      ,           ,          4      # )r   r(   r5   r<   r>   rB   s   &$$$ r   Ú=_get_cosine_with_hard_restarts_schedule_with_warmup_lr_lambdarL   ±   sŒ   € ð Ô&Ü�\Ó"¤U¬3¨qÐ2BÓ+CÓ%DÕDÐDÜ�\Õ4Ó5¼¼cÀ!ÐEWÕEjÓ>kÓ8lÕl€HØ�3„ÙÜˆs�C˜3¤§¢¬$¯'©'´e¸JÓ6GÈ(Õ6RÐVYÕ5YÕ*ZÓ![Õ[Õ\Ó]Ð]r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r   r   r   r&   r   r3   r:   r   r   )r   s   "r   r   r   ¼   s4   € ÷ 6ñ 6Øð6Ø,/ð6ØEHð6ØVYð6Øknñ6r   c                ó@   € \        \        VVVR7      p\        WV4      # )aJ  
Create a schedule with a learning rate that decreases following the values of the cosine function between the
initial lr set in the optimizer to 0, with several hard restarts, after a warmup period during which it increases
linearly between 0 and the initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_training_steps (`int`):
        The total number of training steps.
    num_cycles (`int`, *optional*, defaults to 1):
        The number of hard restarts to use.
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
rG   )r   rL   r   rH   s   &&&&& r   Ú2get_cosine_with_hard_restarts_schedule_with_warmuprO   ¼   s)   € ô0 ÜEØ)Ø-Øô	€Iô �I¨*Ó5Ð5r   c               ó0   € V ^8„  d   QhRRRRRRRRRRRR/# )	r   r%   r   r&   r3   Úlr_endr*   ÚpowerÚlr_initr   )r   s   "r   r   r   Ý   sF   € ÷ ñ Øðð ðð ð	ð
 ðð ðð ñr   c               óü   € W8  d&   \        V 4      \        \        ^V4      4      ,          # W8”  d	   W5,          # WS,
          pW!,
          p^W,
          V,          ,
          pWhV,          ,          V,           p	W•,          # r   r)   )
r%   r&   r3   rQ   rR   rS   Úlr_rangeÚdecay_stepsÚpct_remainingÚdecays
   &$$$$$    r   Ú4_get_polynomial_decay_schedule_with_warmup_lr_lambdarY   Ý   sr   € ð Ô&Ü�\Ó"¤U¬3¨qÐ2BÓ+CÓ%DÕDÐDØ	Ô	*ØÕÐàÕ#ˆØ(Õ;ˆØ˜\Õ<ÀÕKÕKˆØ¨%Õ/Õ/°&Õ8ˆØ�Ðr   c           	     óš   € V P                   R,          pWc8”  g   \        RV RV R24      h\        \        VVVVVR7      p\	        WV4      # )aE  
Create a schedule with a learning rate that decreases as a polynomial decay from the initial lr set in the
optimizer to end lr defined by *lr_end*, after a warmup period during which it increases linearly from 0 to the
initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_training_steps (`int`):
        The total number of training steps.
    lr_end (`float`, *optional*, defaults to 1e-7):
        The end LR.
    power (`float`, *optional*, defaults to 1.0):
        Power factor.
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Note: *power* defaults to 1.0 as in the fairseq implementation, which in turn is based on the original BERT
implementation at
https://github.com/google-research/bert/blob/f39e881b169b9d53bea03d2d341b31707a6c052b/optimization.py#L37

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.

Úlrzlr_end (z#) must be smaller than initial lr (Ú))r&   r3   rQ   rR   rS   )ÚdefaultsÚ
ValueErrorr   rY   r   )r   r&   r3   rQ   rR   r   rS   r0   s   &&&&&&  r   Ú)get_polynomial_decay_schedule_with_warmupr_   ò   sa   € ð> × Ñ  Õ&€GØÔÜ˜8 F 8Ð+NÈwÈiÐWXÐYÓZÐZäÜ<Ø)Ø-ØØØô€Iô �I¨*Ó5Ð5r   Ú	timescalec               ó$   € V ^8„  d   QhRRRRRR/# )r   r%   r   r&   r`   ú
int | Noner   )r   s   "r   r   r      s#   € ÷ ñ °sð ÐQTð Ðakñ r   c               óÀ   € W8  d&   \        V 4      \        \        ^V4      4      ,          # W!,
          pR\        P                  ! W,           V,          4      ,          pV# )r   r(   )r*   r+   r?   Úsqrt)r%   r&   r`   ÚshiftrX   s   &$$  r   Ú$_get_inverse_sqrt_schedule_lr_lambdarf      sM   € ØÔ&Ü�\Ó"¤U¬3¨qÐ2BÓ+CÓ%DÕDÐDØÕ(€EØ”$—)’)˜\Õ1°YÕ>Ó?Õ?€EØ€Lr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   r&   r   r`   rb   r   r   )r   s   "r   r   r   (  s2   € ÷ Añ AØðAØ,/ðAØ<FðAØ[^ñAr   c                ó^   € Vf   T;'       g    Rp\        \        WR7      p\        WVR7      # )a¢  
Create a schedule with an inverse square-root learning rate, from the initial lr set in the optimizer, after a
warmup period which increases lr linearly from 0 to the initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    timescale (`int`, *optional*, defaults to `num_warmup_steps`):
        Time scale.
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
i'  )r&   r`   r   )r   rf   r   )r   r&   r`   r   r0   s   &&&& r   Úget_inverse_sqrt_scheduleri   (  s2   € ð. ÒØ$×.Ð.¨ˆ	äÔ<ÐO_Ôu€IÜ�I°ZÔ@Ð@r   Úmin_lr_rater5   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r   r%   r   r&   r3   r:   r*   rj   r   )r   s   "r   r   r   F  s4   € ÷ ñ ØðØ,/ðØEHðØV[ðØjoñr   c               ó   € W8  d&   \        V 4      \        \        ^V4      4      ,          # \        W,
          4      \        \        ^W!,
          4      4      ,          pRR\        P                  ! \        P                  \        V4      ,          R,          V,          4      ,           ,          pV^V,
          ,          V,           p\        ^ V4      # )r   r<   r(   r=   r>   )r%   r&   r3   r:   rj   rC   Úfactors   &$$$$  r   rD   rD   F  s˜   € ð Ô&Ü�\Ó"¤U¬3¨qÐ2BÓ+CÓ%DÕDÐDÜ�\Õ4Ó5¼¼cÀ!ÐEWÕEjÓ>kÓ8lÕl€HØ�Cœ$Ÿ(š(¤4§7¡7¬U°:Ó->Õ#>ÀÕ#DÀxÕ#OÓPÕPÕQ€FØ�q˜;•Õ'¨+Õ5€FÜˆq�&‹>Ðr   c               ó4   € V ^8„  d   QhRRRRRRRRRRR	R
RR
/# )r   r   r   r&   r   r3   r:   r*   r   Úmin_lrúfloat | Nonerj   r   )r   s   "r   r   r   Q  sN   € ÷ 16ñ 16Øð16àð16ð ð16ð ð	16ð
 ð16ð ð16ð ñ16r   c                óÂ   € Ve   Ve   \        R4      hVe   WPP                  R,          ,          pMVf   \        R4      h\        \        VVVVR7      p\	        WV4      # )a˜  
Create a schedule with a learning rate that decreases following the values of the cosine function between the
initial lr set in the optimizer to min_lr, after a warmup period during which it increases linearly between 0 and the
initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_training_steps (`int`):
        The total number of training steps.
    num_cycles (`float`, *optional*, defaults to 0.5):
        The number of waves in the cosine schedule (the defaults is to just decrease from the max value to 0
        following a half-cosine).
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.
    min_lr (`float`, *optional*):
        The minimum learning rate to reach after the cosine schedule.
    min_lr_rate (`float`, *optional*):
        The minimum learning rate as a ratio of the initial learning rate. If set, `min_lr` should not be set.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
ú/Only one of min_lr or min_lr_rate should be setr[   úLOne of min_lr or min_lr_rate should be set through the `lr_scheduler_kwargs`)r&   r3   r:   rj   )r^   r]   r   rD   r   )r   r&   r3   r:   r   ro   rj   r0   s   &&&&&&& r   Ú+get_cosine_with_min_lr_schedule_with_warmuprt   Q  so   € ðF Ò˜kÒ5ÜÐJÓKÐKØ	Ò	Ø×1Ñ1°$Õ7Õ7‰Ø	Ò	ÜÐgÓhÐhäÜ2Ø)Ø-ØØô€Iô �I¨*Ó5Ð5r   Úwarmup_lr_ratec               ó0   € V ^8„  d   QhRRRRRRRRRRRR	/# )
r   r%   r   r&   r3   r:   r*   rj   ru   rp   r   )r   s   "r   r   r   …  sF   € ÷ ñ Øðð ðð ð	ð
 ðð ðð !ñr   c               ó   € \        V 4      p \        V4      p\        V4      pW8  dY   Vf   V R,           \        RV4      ,          # \        V4      pVRV,
          V ,          \        ^V^,
          4      ,          ,           # W,
          R,           \        RW!,
          4      ,          pRR\        P                  ! \        P                  V,          R,          V,          4      ,           ,          pV^V,
          ,          V,           p\        ^ V4      # )Nr(   r<   r=   r>   )r%   r&   r3   r:   rj   ru   rC   rm   s   &$$$$$  r   Ú;_get_cosine_with_min_lr_schedule_with_warmup_lr_rate_lambdarx   …  sä   € ô ˜Ó&€LÜÐ-Ó.ÐÜÐ1Ó2ÐàÔ&ØÒ!Ø  3Õ&¬#¨cÐ3CÓ*DÕDÐDä" >Ó2ˆNØ! S¨>Õ%9¸lÕ$KÌsÐSTÐVfÐijÕVjÓOkÕ$lÕlÐlØÕ/°#Õ5¼#¸cÐCUÕChÓ:iÕj€HØ�Cœ$Ÿ(š(¤4§7¡7¨ZÕ#7¸#Õ#=ÀÕ#HÓIÕIÕJ€FØ�q˜;•Õ'¨+Õ5€FÜˆq�&‹>Ðr   c               ó8   € V ^8„  d   QhRRRRRRRRRRR	R
RR
RR
/# )r   r   r   r&   r   r3   r:   r*   r   ro   rp   rj   ru   r   )r   s   "r   r   r   ž  sX   € ÷ 56ñ 56Øð56àð56ð ð56ð ð	56ð
 ð56ð ð56ð ð56ð !ñ56r   c           	     óÄ   € Ve   Ve   \        R4      hVe   WPP                  R,          ,          pMVf   \        R4      h\        \        VVVVVR7      p\	        WV4      # )aV  
Create a schedule with a learning rate that decreases following the values of the cosine function between the
initial lr set in the optimizer to min_lr, after a warmup period during which it increases linearly between 0 and the
initial lr set in the optimizer.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_training_steps (`int`):
        The total number of training steps.
    num_cycles (`float`, *optional*, defaults to 0.5):
        The number of waves in the cosine schedule (the defaults is to just decrease from the max value to 0
        following a half-cosine).
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.
    min_lr (`float`, *optional*):
        The minimum learning rate to reach after the cosine schedule.
    min_lr_rate (`float`, *optional*):
        The minimum learning rate as a ratio of the initial learning rate. If set, `min_lr` should not be set.
    warmup_lr_rate (`float`, *optional*):
        The minimum learning rate as a ratio of the start learning rate. If not set, `warmup_lr_rate` will be treated as float(1/num_warmup_steps).

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
rr   r[   rs   )r&   r3   r:   rj   ru   )r^   r]   r   rx   r   )	r   r&   r3   r:   r   ro   rj   ru   r0   s	   &&&&&&&& r   Ú3get_cosine_with_min_lr_schedule_with_warmup_lr_rater{   ž  sr   € ðL Ò˜kÒ5ÜÐJÓKÐKØ	Ò	Ø×1Ñ1°$Õ7Õ7‰Ø	Ò	ÜÐgÓhÐhäÜCØ)Ø-ØØØ%ô€Iô �I¨*Ó5Ð5r   c               ó8   € V ^8„  d   QhRRRRRRRRRRRRR	R
RR
/# )r   r%   r   r&   Únum_stable_stepsÚnum_decay_stepsÚwarmup_typeÚstrÚ
decay_typeÚmin_lr_ratior*   r:   r   )r   s   "r   r   r   Ö  sZ   € ÷ #ñ #Øð#ð ð#ð ð	#ð
 ð#ð ð#ð ð#ð ð#ð ñ#r   c               ó˜  € W8  d¿   \        V 4      \        \        ^V4      4      ,          pVR8X  d   Tp	MlVR8X  d;   RR\        P                  ! \        P                  V,          4      ,
          ,          p	M+VR8X  d%   R\        P
                  ! RV,
          4      ,
          p	X	RV,
          ,          V,           p	\        RV	4      # WV,           8  d   R# WV,           V,           8  dã   \        W,
          V,
          4      \        \        ^V4      4      ,          pVR8X  d   RV,
          p	M|VR8X  dR   RR\        P                  ! \        P                  \        V4      ,          R,          V,          4      ,           ,          p	M$VR8X  d   R\        P
                  ! V4      ,
          p	X	RV,
          ,          V,           p	\        RV	4      # V# )r   ÚlinearÚcosiner<   r(   ú1-sqrtr5   r=   )r*   r+   r?   r@   rA   rd   )
r%   r&   r}   r~   r   r�   r‚   r:   rC   rm   s
   &$$$$$$$  r   Ú_get_wsd_scheduler_lambdar‡   Ö  sn  € ð Ô&Ü˜Ó&¬¬s°1Ð6FÓ/GÓ)HÕHˆØ˜(Ô"Ø‰FØ˜HÔ$Ø˜C¤$§(¢(¬4¯7©7°XÕ+=Ó">Õ>Õ?‰FØ˜HÔ$Øœ4Ÿ9š9 S¨8¥^Ó4Õ4ˆFØ˜3 Õ-Õ.°Õ=ˆÜ�3˜ÓÐàÐ)9Õ9Ô9ÙàÐ)9Õ9¸OÕKÔKÜ˜Õ8Ð;KÕKÓLÌuÔUXÐYZÐ\kÓUlÓOmÕmˆØ˜Ô!Ø˜8•^‰FØ˜8Ô#Ø˜C¤$§(¢(¬4¯7©7´U¸:Ó5FÕ+FÈÕ+LÈxÕ+WÓ"XÕXÕY‰FØ˜8Ô#Øœ4Ÿ9š9 XÓ.Õ.ˆFØ˜3 Õ-Õ.°Õ=ˆÜ�3˜ÓÐØÐr   c               ó@   € V ^8„  d   QhRRRRRRRRRRR	R
RR
RRRRRR/
# )r   r   r   r&   r   r~   r3   rb   r}   r   r€   r�   r‚   r*   r:   r   r   )r   s   "r   r   r   ü  sx   € ÷ F6ñ F6ØðF6àðF6ð ðF6ð #ð	F6ð
 !ðF6ð ðF6ð ðF6ð ðF6ð ðF6ð ñF6r   c
                ó(  € Vf   Vf   \        R4      hVe   Ve   \        P                  ! R4       VR9  d   \        RV R24      hVR9  d   \        RV R24      hVf   W1,
          V,
          p\        \        VVVVVVVR7      p
\        W
V	4      # )a‹  
Create a schedule with a learning rate that has three stages:
1. warmup: increase from min_lr_ratio times the initial learning rate to the initial learning rate following a warmup_type.
2. stable: constant learning rate.
3. decay: decrease from the initial learning rate to min_lr_ratio times the initial learning rate following a decay_type.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    num_warmup_steps (`int`):
        The number of steps for the warmup phase.
    num_decay_steps (`int`):
        The number of steps for the decay phase.
    num_training_steps (`int`, *optional*):
        The total number of training steps. This is the sum of the warmup, stable and decay steps. If `num_stable_steps` is not provided, the stable phase will be `num_training_steps - num_warmup_steps - num_decay_steps`.
    num_stable_steps (`int`, *optional*):
        The number of steps for the stable phase. Please ensure that `num_warmup_steps + num_stable_steps + num_decay_steps` equals `num_training_steps`, otherwise the other steps will default to the minimum learning rate.
    warmup_type (`str`, *optional*, defaults to "linear"):
        The type of warmup to use. Can be 'linear', 'cosine' or '1-sqrt'.
    decay_type (`str`, *optional*, defaults to "cosine"):
        The type of decay to use. Can be 'linear', 'cosine' or '1-sqrt'.
    min_lr_ratio (`float`, *optional*, defaults to 0):
        The minimum learning rate as a ratio of the initial learning rate.
    num_cycles (`float`, *optional*, defaults to 0.5):
        The number of waves in the cosine schedule (the defaults is to just decrease from the max value to 0
        following a half-cosine).
    last_epoch (`int`, *optional*, defaults to -1):
        The index of the last epoch when resuming training.

Return:
    `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
z@Either num_training_steps or num_stable_steps must be specified.zZBoth num_training_steps and num_stable_steps are specified. num_stable_steps will be used.zUnknown warmup type: z), expected 'linear', 'cosine' or '1-sqrt'zUnknown decay type: )r&   r}   r~   r   r�   r‚   r:   )r„   r…   r†   )r^   ÚwarningsÚwarnr   r‡   r   )r   r&   r~   r3   r}   r   r�   r‚   r:   r   r0   s   &&&&&&&&&& r   Úget_wsd_schedulerŒ   ü  s¹   € ðZ Ò!Ð&6Ò&>ÜÐ[Ó\Ð\àÒ%Ð*:Ò*FÜ�ŠÐrÔsàÐ8Ô8ÜÐ0°°Ð=fÐgÓhÐhàÐ7Ô7ÜÐ/°
¨|Ð;dÐeÓfÐfàÒØ-Õ@À?ÕRÐäÜ!Ø)Ø)Ø'ØØØ!Øô	€Iô �I¨*Ó5Ð5r   c                  óJ   € ] tR tRtRtR R ltR R ltR R ltR	 R
 ltRt	R# )ÚStreamingAverageiE  a*  Rolling window average for smoothing metric values.

Maintains a sliding window of values and computes their average,
useful for smoothing noisy metric values before making learning rate decisions.

Args:
    window_size (`int`):
        The maximum number of values to keep in the rolling window.
c               ó    € V ^8„  d   QhRRRR/# )r   Úwindow_sizer   ÚreturnÚNoner   )r   s   "r   r   ÚStreamingAverage.__annotate__P  s   € ÷ ñ  Cð ¨Dñ r   c                	ó.   € Wn         . V n        R V n        R# )r5   N©r�   ÚvaluesÚsum)Úselfr�   s   &&r   Ú__init__ÚStreamingAverage.__init__P  s   € Ø +ÔØ#%ˆŒØˆŽr   c               ó    € V ^8„  d   QhRRRR/# )r   Úvaluer*   r‘   r   )r   s   "r   r   r“   U  s   € ÷ 	+ñ 	+˜uð 	+¨ñ 	+r   c                óf  € V P                   P                  V4       V ;P                  V,          un        \        V P                   4      V P                  8”  d5   V P                   P                  ^ 4      pV ;P                  V,          un        V P                  \        V P                   4      ,          # )z3Add a value and return the current rolling average.)r–   Úappendr—   Úlenr�   Úpop)r˜   rœ   Úremoveds   && r   Ú	streamavgÚStreamingAverage.streamavgU  sq   € à�‰×Ñ˜5Ô!Ø�Š�EÕ�äˆt�{‰{Ó˜d×.Ñ.Ô.Ø—k‘k—o‘o aÓ(ˆGØ�HŠH˜Õ�Hà�x‰xœ#˜dŸk™kÓ*Õ*Ð*r   c               ó   € V ^8„  d   QhRR/# ©r   r‘   údict[str, Any]r   )r   s   "r   r   r“   `  s   € ÷ 
ñ 
˜Nñ 
r   c                	ój   € R V P                   RV P                  P                  4       RV P                  /# r•   )r�   r–   Úcopyr—   ©r˜   s   &r   Ú
state_dictÚStreamingAverage.state_dict`  s2   € à˜4×+Ñ+Ø�d—k‘k×&Ñ&Ó(Ø�4—8‘8ð
ð 	
r   c               ó    € V ^8„  d   QhRRRR/# ©r   rª   r¦   r‘   r’   r   )r   s   "r   r   r“   g  s   € ÷ .ñ .¨.ð .¸Tñ .r   c                	óÀ   € VP                  R V P                  4      V n        VP                  R. 4      P                  4       V n        VP                  RR4      V n        R# )r�   r–   r—   r5   N)Úgetr�   r¨   r–   r—   )r˜   rª   s   &&r   Úload_state_dictÚ StreamingAverage.load_state_dictg  sH   € Ø%Ÿ>™>¨-¸×9IÑ9IÓJˆÔØ —n‘n X¨rÓ2×7Ñ7Ó9ˆŒØ—>‘> %¨Ó-ˆŽr   )r—   r–   r�   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r™   r¢   rª   r°   Ú__static_attributes__r   r   r   rŽ   rŽ   E  s    † ñõõ
	+õ
÷.ñ .r   rŽ   c                  óŽ   € ] tR tRtR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 ltR R ltR R ltRtR# )ÚGreedyLRim  aÙ
  Adaptive learning rate scheduler that responds to training metrics.

GreedyLR dynamically adjusts the learning rate based on training performance:
- Increases LR when metrics improve consistently (divides by factor)
- Decreases LR when metrics plateau (multiplies by factor)

This differs from traditional schedulers like cosine annealing by responding
to actual training dynamics rather than following a predetermined schedule.

Reference: `GreedyLR: A Novel Adaptive Learning Rate Scheduler <https://arxiv.org/abs/2512.14527>`_

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    mode (`str`, *optional*, defaults to `"min"`):
        One of 'min' or 'max'. In 'min' mode, LR will be reduced when the
        metric has stopped decreasing; in 'max' mode when it has stopped increasing.
    factor (`float`, *optional*, defaults to 0.95):
        Factor by which the learning rate will be adjusted. LR is multiplied by
        factor on plateau and divided by factor on improvement. Must be < 1.0.
    patience (`int`, *optional*, defaults to 10):
        Number of epochs with no improvement after which learning rate will be adjusted.
    threshold (`float`, *optional*, defaults to 1e-06):
        Threshold for measuring the new optimum.
    threshold_mode (`str`, *optional*, defaults to `"abs"`):
        One of 'rel' or 'abs'.
    cooldown (`int`, *optional*, defaults to 0):
        Number of epochs to wait before resuming normal operation after LR has been reduced.
    warmup (`int`, *optional*, defaults to 0):
        Number of epochs to wait before resuming normal operation after LR has been increased.
    min_lr (`float` or `list[float]`, *optional*, defaults to 0.001):
        A lower bound on the learning rate.
    max_lr (`float` or `list[float]`, *optional*, defaults to 1.0):
        An upper bound on the learning rate.
    eps (`float`, *optional*, defaults to 1e-08):
        Minimal decay applied to lr.
    verbose (`bool`, *optional*, defaults to `False`):
        If True, prints a message to stdout for each update.
    smooth (`bool`, *optional*, defaults to `False`):
        If True, applies streaming average smoothing to metrics.
    window_size (`int`, *optional*, defaults to 50):
        The window size for the streaming average when smooth=True.
    reset_start (`int`, *optional*, defaults to 500):
        Number of steps to wait at min_lr before resetting to initial state.

Example:
    ```python
    >>> optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
    >>> scheduler = GreedyLR(optimizer, mode="min", patience=10)
    >>> for epoch in range(100):
    ...     train(...)
    ...     val_loss = validate(...)
    ...     scheduler.step(val_loss)
    ```
c                óX   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRRRRRRRRRRRRRR/# )r   r   r   Úmoder€   rm   r*   Úpatiencer   Ú	thresholdÚthreshold_modeÚcooldownÚwarmupro   zfloat | list[float]Úmax_lrÚepsÚverboseÚboolÚsmoothr�   Úreset_startr‘   r’   r   )r   s   "r   r   ÚGreedyLR.__annotate__¦  sÎ   € ÷ E@ñ E@àðE@ð ðE@ð ð	E@ð
 ðE@ð ðE@ð ðE@ð ðE@ð ðE@ð $ðE@ð $ðE@ð ðE@ð ðE@ð ðE@ð ðE@ð  ð!E@ð" 
ñ#E@r   c                	óx  € VR 8¼  d   \        R4      h\        V\        4      '       g"   \        \	        V4      P
                   R24      hWn        W0n        W@n        WÀn	        Wpn
        W€n        ^ V n        ^ V n        W n        WPn        W`n        W°n        WÐn        Wàn        Wðn        Wðn        ^ V n        \        V	\.        \0        34      '       db   \3        V	4      \3        VP4                  4      8w  d.   \        R\3        VP4                  4       R\3        V	4       24      h\/        V	4      V n        M"V	.\3        VP4                  4      ,          V n        \        V
\.        \0        34      '       db   \3        V
4      \3        VP4                  4      8w  d.   \        R\3        VP4                  4       R\3        V
4       24      h\/        V
4      V n        M"V
.\3        VP4                  4      ,          V n        VP4                   Uu. uF  pVR,          NK  	  upV n        V P:                  P=                  4       V n        VR8X  d   \A        R4      M
\A        R	4      V n!        ^ V n"        ^ V n#        VR9  d   \        R
V R24      hVR9  d   \        RV R24      hRV n$        V'       d   \K        V4      V n$        R# R# u upi )r(   zFactor should be < 1.0.z is not an Optimizerz	expected z min_lrs, got z max_lrs, got r[   ÚminÚinfú-infzmode z is unknown!zthreshold mode N)rÉ   r+   )ÚrelÚabs)&r^   Ú
isinstancer   Ú	TypeErrorÚtyper²   r   rm   r¼   rÃ   r¿   rÀ   Úcooldown_counterÚwarmup_counterr»   r½   r¾   rÂ   rÅ   r�   rÆ   Úreset_start_originalr   ÚlistÚtuplerŸ   Úparam_groupsÚmin_lrsÚmax_lrsÚ	_init_lrsr¨   Ú_last_lrr*   ÚbestÚnum_bad_epochsÚnum_good_epochsÚ_streaming_avgrŽ   )r˜   r   r»   rm   r¼   r½   r¾   r¿   rÀ   ro   rÁ   rÂ   rÃ   rÅ   r�   rÆ   Úgroups   &&&&&&&&&&&&&&&& r   r™   ÚGreedyLR.__init__¦  sN  € ð$ �SŒ=ÜÐ6Ó7Ð7Ü˜)¤Y×/Ò/Üœt I›×7Ñ7Ð8Ð8LÐMÓNÐNà"ŒØŒØ ŒØŒØ ŒØŒØ !ˆÔØˆÔØŒ	Ø"ŒØ,ÔØŒØŒØ&ÔØ&ÔØ$/Ô!ØˆŒä�fœt¤U˜m×,Ò,Ü�6‹{œc )×"8Ñ"8Ó9Ô9Ü  9¬S°×1GÑ1GÓ-HÐ,IÈÔX[Ð\bÓXcÐWdÐ!eÓfÐfÜ ›<ˆD�Là"˜8¤c¨)×*@Ñ*@Ó&AÕAˆDŒLä�fœt¤U˜m×,Ò,Ü�6‹{œc )×"8Ñ"8Ó9Ô9Ü  9¬S°×1GÑ1GÓ-HÐ,IÈÔX[Ð\bÓXcÐWdÐ!eÓfÐfÜ ›<ˆD�Là"˜8¤c¨)×*@Ñ*@Ó&AÕAˆDŒLà3<×3IÒ3IÓJÑ3I¨%˜% Ÿ+˜+Ñ3IÑJˆŒØŸ™×+Ñ+Ó-ˆŒà+/°5¬=œ5 œ<¼eÀF»mˆŒ	ØˆÔØ ˆÔà�~Ô%Ü˜u T F¨,Ð7Ó8Ð8Ø Ô/Ü˜¨~Ð.>¸lÐKÓLÐLà7;ˆÔßÜ"2°;Ó"?ˆDÖñ ùò Ks   Ç?J7Nc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úmetricsr*   Úepochrb   r‘   r’   r   )r   s   "r   r   rÇ   í  s&   € ÷ ,Oñ ,O˜Eð ,O¨*ð ,OÀñ ,Or   c                ó   € \        V4      pV P                  '       d*   V P                  e   V P                  P                  V4      pVf   V P                  ^,           pW n        V P
                  ^ 8”  d*   V ;P
                  ^,          un        ^ V n        ^ V n        EM*V P                  ^ 8”  d)   V ;P                  ^,          un        ^ V n        ^ V n        MñV P                  W0P                  4      '       d(   W0n
        ^ V n        V ;P                  ^,          un        M V ;P                  ^,          un        ^ V n        V P                  V P                  8”  d+   V P                  V4       V P                  V n        ^ V n        MDV P                  V P                  8”  d*   V P                  V4       V P                  V n        ^ V n        V P                   P"                   Uu. uF  qDR,          NK  	  upV n        R# u upi )zñPerform a scheduler step based on the given metrics.

Args:
    metrics (`float`):
        The metric value to use for LR adjustment decisions.
    epoch (`int`, *optional*):
        The current epoch number. If None, uses internal counter.
Nr[   )r*   rÅ   rÞ   r¢   r   rÑ   rÜ   rÝ   rÒ   Ú	is_betterrÛ   r¼   Ú_increase_lrrÀ   Ú
_reduce_lrr¿   r   rÖ   rÚ   )r˜   râ   rã   Úcurrentrß   s   &&&  r   ÚstepÚGreedyLR.stepí  s†  € ô ˜“.ˆà�;�;ˆ;˜4×.Ñ.Ò:Ø×)Ñ)×3Ñ3°GÓ<ˆGàŠ=Ø—O‘O aÕ'ˆEØŒà× Ñ  1Ô$Ø×!Ò! QÕ&Õ!Ø"#ˆDÔØ#$ˆDÖ Ø× Ñ  1Ô$Ø×Ò 1Õ$ÕØ"#ˆDÔØ#$ˆDÕ à�~‰~˜g§y¡y×1Ò1Ø#”	Ø&'�Ô#Ø×$Ò$¨Õ)Ö$à×#Ò# qÕ(Õ#Ø'(�Ô$à×#Ñ# d§m¡mÔ3Ø×!Ñ! %Ô(Ø&*§k¡k�Ô#Ø'(�Õ$Ø×$Ñ$ t§}¡}Ô4Ø—‘ Ô&Ø(,¯©�Ô%Ø&'�Ô#à26·.±.×2MÒ2MÓNÑ2M¨˜tŸ˜Ñ2MÑNˆŽùÒNs   Ç G;c               ó$   € V ^8„  d   QhRRRRRR/# )r   rè   r*   rÛ   r‘   rÄ   r   )r   s   "r   r   rÇ     s!   € ÷ 
7ñ 
7 ð 
7¨eð 
7¸ñ 
7r   c                	ó,  € V P                   R 8X  dC   V P                  R8X  d   WRV P                  ,
          ,          8  # WV P                  ,
          8  # V P                  R8X  d   WRV P                  ,           ,          8„  # WV P                  ,           8„  # )rÉ   rÌ   r(   )r»   r¾   r½   )r˜   rè   rÛ   s   &&&r   rå   ÚGreedyLR.is_better  s|   € Ø�9‰9˜ÔØ×"Ñ" eÔ+Ø¨¨t¯~©~Õ)=Õ!>Ñ>Ð>à¨¯©Õ!6Ñ6Ð6à×"Ñ" eÔ+Ø¨¨t¯~©~Õ)=Õ!>Ñ>Ð>à¨¯©Õ!6Ñ6Ð6r   c               ó    € V ^8„  d   QhRRRR/# ©r   rã   r   r‘   r’   r   )r   s   "r   r   rÇ   '  s   € ÷ ñ  ð ¨ñ r   c           
     	ó0  € R p\        V P                  P                  4       Fª  w  r4\        VR,          4      p\	        WPP
                  ,          V P                  V,          4      pWV,
          V P                  8”  d-   WdR&   V P                  '       d   \        RV RV RVR R24       VR,          V P                  V,          8”  g   K¨  RpK¬  	  V'       d?   V ;P                  ^,          un
        V P                  ^ 8:  d   V P                  4        R# R# R# )	Tr[   úEpoch z": reducing learning rate of group ú to ú.4eÚ.FN)Ú	enumerater   rÖ   r*   r+   rm   r×   rÂ   rÃ   ÚprintrÆ   Ú_reset)r˜   rã   Ú
all_at_minÚiÚparam_groupÚold_lrÚnew_lrs   &&     r   rç   ÚGreedyLR._reduce_lr'  sá   € Øˆ
Ü'¨¯©×(CÑ(CÖD‰NˆAÜ˜; tÕ,Ó-ˆFÜ˜§+¡+Õ-¨t¯|©|¸A­Ó?ˆFà� §¡Ô)Ø$*˜DÑ!Ø—<—<�<Ü˜F 5 'Ð)KÈAÈ3ÈdÐSYÐZ]ÐR^Ð^_Ð`Ôaà˜4Õ  4§<¡<°¥?Ö2Ø"’
ñ E÷ Ø×Ò Õ!ÕØ×Ñ 1Ô$Ø—‘–ñ %ñ r   c               ó    € V ^8„  d   QhRRRR/# rï   r   )r   s   "r   r   rÇ   :  s   € ÷ 
5ñ 
5 #ð 
5¨$ñ 
5r   c           
     	ó„  € \        V P                  P                  4       F‹  w  r#\        VR ,          4      p\	        W@P
                  ,          V P                  V,          4      pWT,
          V P                  8”  g   K]  WSR &   V P                  '       g   Ku  \        RV RV RVR R24       K�  	  V P                  V n        R# )r[   rñ   z$: increasing learning rate of group rò   ró   rô   N)rõ   r   rÖ   r*   rÉ   rm   rØ   rÂ   rÃ   rö   rÓ   rÆ   )r˜   rã   rù   rú   rû   rü   s   &&    r   ræ   ÚGreedyLR._increase_lr:  sœ   € Ü'¨¯©×(CÑ(CÖD‰NˆAÜ˜; tÕ,Ó-ˆFÜ˜§+¡+Õ-¨t¯|©|¸A­Ó?ˆFà� §¡Ö)Ø$*˜DÑ!Ø—<—<’<Ü˜F 5 'Ð)MÈaÈSÐPTÐU[Ð\_ÐT`Ð`aÐbÖcñ Eð  ×4Ñ4ˆÖr   c               ó   € V ^8„  d   QhRR/# )r   r‘   r’   r   )r   s   "r   r   rÇ   F  s   € ÷ 7ñ 7˜ñ 7r   c                	óæ  € \        V P                  P                  4       F  w  rV P                  V,          VR &   K  	  V P                  R8X  d   \        R4      M
\        R4      V n        ^ V n        ^ V n        ^ V n	        ^ V n
        V P                  V n        V P                  '       d)   V P                  e   \        V P                   4      V n        V P"                  '       d   \%        R4       R# R# )r[   rÉ   rÊ   rË   Nz!Scheduler reset to initial state.)rõ   r   rÖ   rÙ   r»   r*   rÛ   rÜ   rÝ   rÑ   rÒ   rÓ   rÆ   rÅ   rÞ   rŽ   r�   rÃ   rö   )r˜   rù   rú   s   &  r   r÷   ÚGreedyLR._resetF  s»   € Ü'¨¯©×(CÑ(CÖD‰NˆAØ $§¡¨qÕ 1ˆK˜Óñ Eð %)§I¡I°Ô$6”E˜%”L¼EÀ&»MˆŒ	ØˆÔØ ˆÔØ !ˆÔØˆÔØ×4Ñ4ˆÔà�;�;ˆ;˜4×.Ñ.Ò:Ü"2°4×3CÑ3CÓ"DˆDÔà�<�<ˆ<ÜÐ5Ö6ñ r   c               ó   € V ^8„  d   QhRR/# )r   r‘   zlist[float]r   )r   s   "r   r   rÇ   W  s   € ÷ ñ ˜[ñ r   c                ó   € V P                   # )z8Return last computed learning rate by current scheduler.)rÚ   r©   s   &r   Úget_last_lrÚGreedyLR.get_last_lrW  s   € à�}‰}Ðr   c               ó   € V ^8„  d   QhRR/# r¥   r   )r   s   "r   r   rÇ   [  s   € ÷ ñ ˜Nñ r   c                óÒ  € / RV P                   bRV P                  bRV P                  bRV P                  bRV P                  bRV P
                  bRV P                  bRV P                  bR	V P                  bR
V P                  bRV P                  bRV P                  bRV P                  bRV P                  bRV P                  bRV P                  bRV P                   bRV P"                  RV P$                  RV P&                  RV P(                  RV P*                  RV P,                  /CpV P"                  '       d,   V P.                  e   V P.                  P1                  4       VR&   V# )z2Return the state of the scheduler as a dictionary.rm   r×   rØ   r¼   rÃ   r¿   rÀ   rÑ   rÒ   r»   r½   r¾   rÛ   rÜ   rÝ   rÂ   r   rÅ   r�   rÆ   rÓ   rÚ   rÙ   rÞ   )rm   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˜   Ústates   & r   rª   ÚGreedyLR.state_dict[  s—  € ð
Ø�d—k‘kð
à�t—|‘|ð
ð �t—|‘|ð
ð ˜Ÿ™ð	
ð
 �t—|‘|ð
ð ˜Ÿ™ð
ð �d—k‘kð
ð  × 5Ñ 5ð
ð ˜d×1Ñ1ð
ð �D—I‘Ið
ð ˜Ÿ™ð
ð ˜d×1Ñ1ð
ð �D—I‘Ið
ð ˜d×1Ñ1ð
ð ˜t×3Ñ3ð
ð  �4—8‘8ð!
ð" ˜$Ÿ/™/ð#
ð$ �d—k‘kØ˜4×+Ñ+Ø˜4×+Ñ+Ø" D×$=Ñ$=Ø˜Ÿ™Ø˜Ÿ™ñ/
ˆð4 �;�;ˆ;˜4×.Ñ.Ò:Ø&*×&9Ñ&9×&DÑ&DÓ&FˆEÐ"Ñ#àˆr   c               ó    € V ^8„  d   QhRRRR/# r­   r   )r   s   "r   r   rÇ   |  s   € ÷ !'ñ !'¨.ð !'¸Tñ !'r   c                ó  € VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P
                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  R	V P                  4      V n	        VP                  R
V P                  4      V n
        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P                   4      V n        VP                  RV P"                  4      V n        VP                  RV P$                  4      V n        VP                  RV P&                  4      V n        VP                  RV P(                  4      V n        VP                  RV P*                  4      V n        VP                  RV P,                  4      V n        VP                  RV P.                  4      V n        RV9   dK   V P0                  f   \3        V P&                  4      V n        V P0                  P5                  VR,          4       RV9   d:   \7        V P8                  P:                  V P,                  4       F	  w  r#W2R&   K  	  R# R# )zLoad state from a dictionary.rm   r×   rØ   r¼   rÃ   r¿   rÀ   rÑ   rÒ   r»   r½   r¾   rÛ   rÜ   rÝ   rÂ   r   rÅ   r�   rÆ   rÓ   rÚ   rÙ   rÞ   Nr[   )r¯   rm   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°   Úzipr   rÖ   )r˜   rª   rú   r[   s   &&  r   r°   ÚGreedyLR.load_state_dict|  s’  € à —n‘n X¨t¯{©{Ó;ˆŒØ!—~‘~ i°·±Ó>ˆŒØ!—~‘~ i°·±Ó>ˆŒØ"Ÿ™ z°4·=±=ÓAˆŒØ!—~‘~ i°·±Ó>ˆŒØ"Ÿ™ z°4·=±=ÓAˆŒØ —n‘n X¨t¯{©{Ó;ˆŒØ *§¡Ð/AÀ4×CXÑCXÓ YˆÔØ(Ÿn™nÐ-=¸t×?RÑ?RÓSˆÔØ—N‘N 6¨4¯9©9Ó5ˆŒ	Ø#Ÿ™¨°T·^±^ÓDˆŒØ(Ÿn™nÐ-=¸t×?RÑ?RÓSˆÔØ—N‘N 6¨4¯9©9Ó5ˆŒ	Ø(Ÿn™nÐ-=¸t×?RÑ?RÓSˆÔØ)Ÿ~™~Ð.?À×AUÑAUÓVˆÔØ—>‘> %¨¯©Ó2ˆŒØ$Ÿ.™.¨°t·±ÓGˆŒØ —n‘n X¨t¯{©{Ó;ˆŒØ%Ÿ>™>¨-¸×9IÑ9IÓJˆÔØ%Ÿ>™>¨-¸×9IÑ9IÓJˆÔØ$.§N¡NÐ3IÈ4×KdÑKdÓ$eˆÔ!Ø"Ÿ™ z°4·=±=ÓAˆŒØ#Ÿ™¨°T·^±^ÓDˆŒà˜zÔ)Ø×"Ñ"Ò*Ü&6°t×7GÑ7GÓ&H�Ô#Ø×Ñ×/Ñ/°
Ð;KÕ0LÔMà˜Ô#Ü#& t§~¡~×'BÑ'BÀDÇMÁMÖ#R‘�Ø$&˜DÓ!ó $Sñ $r   )rÙ   rÚ   rÞ   rÛ   r¿   rÑ   rÂ   rm   r   rØ   r×   r»   rÜ   rÝ   r   r¼   rÆ   rÓ   rÅ   r½   r¾   rÃ   rÀ   rÒ   r�   )rÉ   gffffffî?é
   ç�íµ ÷Æ°>rÍ   é    r  çü©ñÒMbP?r(   g:Œ0âŽyE>FFé2   iô  ©N)r²   r³   r´   rµ   r¶   r™   ré   rå   rç   ræ   r÷   r  rª   r°   r·   r   r   r   r¹   r¹   m  s@   † ñ6÷pE@÷N,Oõ\
7õõ&
5õ7õ"õ÷B!'ñ !'r   r¹   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r      s   € ÷ )ñ ) 9ñ )r   c                ó   € \        V 3/ VB # )a  
Create an adaptive learning rate scheduler that adjusts LR based on training metrics.

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    kwargs (`dict`, *optional*):
        Extra parameters passed to the scheduler. See [`GreedyLR`] for possible parameters.

Return:
    [`GreedyLR`] with the appropriate schedule.
)r¹   r!   s   &,r   Úget_greedy_scheduler     s   € ô �IÑ( Ñ(Ð(r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   Únamezstr | SchedulerTyper   r   r&   rb   r3   Úscheduler_specific_kwargszdict | Noner   )r   s   "r   r   r   À  sA   € ÷ ^ñ ^Ø
ð^àð^ð !ð^ð #ð	^ð
  +ñ^r   c           	     óJ  a	€ \        V 4      p \        V ,          pVe˜   \        V\        4      '       d‚   VP                  p/ o	V F  p\        V Wg,          VVVR7      S	V&   K  	  V	3R lpV F(  pVP                  '       g   K  VP                  V4       K*  	  \        WaP                  R,          R7      # V \         P                  8X  d	   V! V4      # Vf   / pV \         P                  8X  d
   V! V3/ VB # V \         P                  8X  d
   V! V3/ VB # Vf   \        V  R24      hV \         P                  8X  d
   V! WR7      # V \         P                  8X  d   V! V3RV/VB # V \         P                   8X  d   V! V3RVRV/VB # Vf   \        V  R	24      hV! V3RVRV/VB # )
aÒ  
Unified API to get any scheduler from its name.

Args:
    name (`str` or `SchedulerType`):
        The name of the scheduler to use.
    optimizer (`torch.optim.Optimizer`):
        The optimizer that will be used during training.
    num_warmup_steps (`int`, *optional*):
        The number of warmup steps to do. This is not required by all schedulers (hence the argument being
        optional), the function will raise an error if it's unset and the scheduler type requires it.
    num_training_steps (`int``, *optional*):
        The number of training steps to do. This is not required by all schedulers (hence the argument being
        optional), the function will raise an error if it's unset and the scheduler type requires it.
    scheduler_specific_kwargs (`dict`, *optional*):
        Extra parameters for schedulers such as cosine with restarts. Mismatched scheduler types and scheduler
        parameters will cause the scheduler function to raise a TypeError.
)r   r&   r3   r  c                ó6   <€ SV ,          P                  4        R # r  )ré   )ÚparamÚscheduler_dicts   &€r   Úscheduler_hookÚ%get_scheduler.<locals>.scheduler_hookë  s   ø€ ð ˜5Õ!×&Ñ&Ö(r   r[   )Úoptimizer_dictr[   z; requires `num_warmup_steps`, please provide that argument.r/   r&   r3   z= requires `num_training_steps`, please provide that argument.)r
   ÚTYPE_TO_SCHEDULER_FUNCTIONrÎ   r   r"  Úget_schedulerÚrequires_gradÚ"register_post_accumulate_grad_hookr	   r]   ÚCONSTANTÚREDUCE_ON_PLATEAUÚGREEDYr^   ÚCONSTANT_WITH_WARMUPÚINVERSE_SQRTÚWARMUP_STABLE_DECAY)
r  r   r&   r3   r  Úschedule_funcr"  r  r   r  s
   &&&&&    @r   r$  r$  À  sì  ø€ ô2 ˜Ó€DÜ.¨tÕ4€Mð Ò¤¨IÔ7N×!OÒ!OØ"×1Ñ1ˆØˆã#ˆEÜ$1ØØ(Õ/Ø!1Ø#5Ø*Cô%ˆN˜5Ó!ñ $õ	)ó
 $ˆEØ×"×"Ò"Ø×8Ñ8¸ÖHñ $ô '°n×I[ÑI[Ð\`ÕIaÔbÐbàŒ}×%Ñ%Ô%Ù˜YÓ'Ð'à Ò(Ø$&Ð!àŒ}×.Ñ.Ô.Ù˜YÑDÐ*CÑDÐDàŒ}×#Ñ#Ô#Ù˜YÑDÐ*CÑDÐDð ÒÜ˜D˜6Ð!\Ð]Ó^Ð^àŒ}×1Ñ1Ô1Ù˜YÔJÐJàŒ}×)Ñ)Ô)Ù˜YÑgÐ9IÐgÐMfÑgÐgð Œ}×0Ñ0Ô0ÙØñ
à-ð
ð  2ð
ð (ñ	
ð 	
ð Ò!Ü˜D˜6Ð!^Ð_Ó`Ð`áØñà)ðð .ðð $ñ	ð r   c                  ó¢   a € ] tR tRtRtR
V 3R llt]R 4       t]R 4       t]R 4       t	]R 4       t
]P                  ! 4       RR l4       tR	tV ;t# )Ú	Adafactori!  a-  
AdaFactor pytorch implementation can be used as a drop in replacement for Adam original fairseq code:
https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py

Paper: *Adafactor: Adaptive Learning Rates with Sublinear Memory Cost* https://huggingface.co/papers/1804.04235 Note that
this optimizer internally adjusts the learning rate depending on the `scale_parameter`, `relative_step` and
`warmup_init` options. To use a manual (external) learning rate schedule you should set `scale_parameter=False` and
`relative_step=False`.

Arguments:
    params (`Iterable[nn.parameter.Parameter]`):
        Iterable of parameters to optimize or dictionaries defining parameter groups.
    lr (`float`, *optional*):
        The external learning rate.
    eps (`tuple[float, float]`, *optional*, defaults to `(1e-30, 0.001)`):
        Regularization constants for square gradient and parameter scale respectively
    clip_threshold (`float`, *optional*, defaults to 1.0):
        Threshold of root mean square of final gradient update
    decay_rate (`float`, *optional*, defaults to -0.8):
        Coefficient used to compute running averages of square
    beta1 (`float`, *optional*):
        Coefficient used for computing running averages of gradient
    weight_decay (`float`, *optional*, defaults to 0.0):
        Weight decay (L2 penalty)
    scale_parameter (`bool`, *optional*, defaults to `True`):
        If True, learning rate is scaled by root mean square
    relative_step (`bool`, *optional*, defaults to `True`):
        If True, time-dependent learning rate is computed instead of external learning rate
    warmup_init (`bool`, *optional*, defaults to `False`):
        Time-dependent learning rate computation depends on whether warm-up initialization is being used

This implementation handles low-precision (FP16, bfloat) values, but we have not thoroughly tested.

Recommended T5 finetuning settings (https://discuss.huggingface.co/t/t5-finetuning-tips/684/3):

    - Training without LR warmup or clip_threshold is not recommended.

       - use scheduled LR warm-up to fixed LR
       - use clip_threshold=1.0 (https://huggingface.co/papers/1804.04235)
    - Disable relative updates
    - Use scale_parameter=False
    - Additional optimizer operations like gradient clipping should not be used alongside Adafactor

Example:

```python
Adafactor(model.parameters(), scale_parameter=False, relative_step=False, warmup_init=False, lr=1e-3)
```

Others reported the following combination to work well:

```python
Adafactor(model.parameters(), scale_parameter=True, relative_step=True, warmup_init=True, lr=None)
```

When using `lr=None` with [`Trainer`] you will most likely need to use [`~optimization.AdafactorSchedule`]
scheduler as following:

```python
from transformers.optimization import Adafactor, AdafactorSchedule

optimizer = Adafactor(model.parameters(), scale_parameter=True, relative_step=True, warmup_init=True, lr=None)
lr_scheduler = AdafactorSchedule(optimizer)
trainer = Trainer(..., optimizers=(optimizer, lr_scheduler))
```

Usage:

```python
# replace AdamW with Adafactor
optimizer = Adafactor(
    model.parameters(),
    lr=1e-3,
    eps=(1e-30, 1e-3),
    clip_threshold=1.0,
    decay_rate=-0.8,
    beta1=None,
    weight_decay=0.0,
    relative_step=False,
    scale_parameter=False,
    warmup_init=False,
)
```c                	ó²   <€ Ve   V	'       d   \        R4      hV
'       d   V	'       g   \        R4      hRVRVRVRVRVRVR	VR
V	RV
/	p\        SV `	  W4       R # )Nz;Cannot combine manual `lr` and `relative_step=True` optionsz0`warmup_init=True` requires `relative_step=True`r[   rÂ   Úclip_thresholdÚ
decay_rateÚbeta1Úweight_decayÚscale_parameterÚrelative_stepÚwarmup_init)r^   Úsuperr™   )r˜   Úparamsr[   rÂ   r1  r2  r3  r4  r5  r6  r7  r]   Ú	__class__s   &&&&&&&&&&& €r   r™   ÚAdafactor.__init__v  sn   ø€ ð Š>ŸmÜÐZÓ[Ð[ßŸ}ÜÐOÓPÐPð �"Ø�3Ø˜nØ˜*Ø�UØ˜LØ˜Ø˜]Ø˜;ð

ˆô 	‰Ñ˜Ö*r   c                	óD  € V R ,          pV R,          '       dP   V R,          '       d   RVR,          ,          MRp\        VR\        P                  ! VR,          4      ,          4      pRpV R,          '       d"   \        V R,          ^,          VR	,          4      pWB,          # )
r[   r6  r7  r  ré   g{®Gáz„?r(   r5  rÂ   ÚRMS)rÉ   r?   rd   r+   )rú   Úparam_stateÚrel_step_szÚmin_stepÚparam_scales   &&   r   Ú_get_lrÚAdafactor._get_lr•  s‡   € à! $Õ'ˆØ�×'Ô'Ø5@À×5OÔ5O�t˜k¨&Õ1Ö1ÐUYˆHÜ˜h¨¬d¯iªi¸ÀFÕ8KÓ.LÕ(LÓMˆKØˆØÐ(×)Ô)Ü˜k¨%Õ0°Õ3°[ÀÕ5GÓHˆKØÕ(Ð(r   c                	ó:   € \        V4      ^8¬  pV R,          RJpW#3# )r   r3  N)rŸ   )rú   Úparam_shapeÚfactoredÚuse_first_moments   &&  r   Ú_get_optionsÚAdafactor._get_options   s*   € ä�{Ó# qÑ(ˆØ& wÕ/°tÐ;ÐØÐ)Ð)r   c                	ó\   € V P                  ^4      V P                  4       R,          ,          # )r   r<   )ÚnormÚnumel)Útensors   &r   Ú_rmsÚAdafactor._rms¦  s    € à�{‰{˜1‹~ §¡£°3Õ!6Õ7Ð7r   c                	óØ   € W P                  RRR7      ,          P                  4       P                  R4      pVP                  R4      P                  4       p\        P
                  ! W#4      # )r   T)ÚdimÚkeepdiméÿÿÿÿéþÿÿÿ)ÚmeanÚrsqrt_Ú	unsqueezeÚrsqrtÚtorchÚmul)Úexp_avg_sq_rowÚexp_avg_sq_colÚr_factorÚc_factors   &&  r   Ú_approx_sq_gradÚAdafactor._approx_sq_gradª  sY   € ð #×%8Ñ%8¸RÈÐ%8Ó%NÕN×VÑVÓX×bÑbÐceÓfˆØ!×+Ñ+¨BÓ/×5Ñ5Ó7ˆÜ�yŠy˜Ó,Ð,r   c                óü	  € RpVe   V! 4       pV P                    EFÝ  pVR,           EFË  pVP                  f   K  VP                  pVP                  \        P                  \        P
                  09   d   VP                  4       pVP                  '       d   \        R4      hV P                  V,          pVP                  pV P                  W74      w  r‰\        V4      ^ 8X  d¯   ^ VR&   V	'       d   \        P                  ! V4      VR&   V'       db   \        P                  ! VRR 4      P                  V4      VR&   \        P                  ! VRR VRR ,           4      P                  V4      VR&   M\        P                  ! V4      VR&   ^ VR	&   M}V	'       d   VR,          P                  V4      VR&   V'       d8   VR,          P                  V4      VR&   VR,          P                  V4      VR&   MVR,          P                  V4      VR&   Tp
VP                  \        P                  \        P
                  09   d   V
P                  4       p
VR;;,          ^,          uu&   V P!                  V
4      VR	&   V P#                  W64      pR
\$        P&                  ! VR,          VR,          4      ,
          pV^,          VR,          ^ ,          ,           pV'       d¨   VR,          pVR,          pVP)                  V4      P+                  VP-                  RR7      R
V,
          R7       VP)                  V4      P+                  VP-                  RR7      R
V,
          R7       V P/                  Wï4      pVP)                  V4       MQVR,          pVP)                  V4      P+                  VR
V,
          R7       VP1                  4       P)                  V4      pVP3                  V P!                  V4      VR,          ,          P5                  R
R7      4       VP)                  V4       V	'       dC   VR,          pVP)                  VR,          4      P+                  V^VR,          ,
          R7       TpVR,          ^ 8w  d"   V
P+                  W£R,          ) V,          R7       V
P+                  V) 4       VP                  \        P                  \        P
                  09   g   EKº  VP7                  V
4       EKÎ  	  EKà  	  V# )z–
Performs a single optimization step

Arguments:
    closure (callable, optional): A closure that reevaluates the model
        and returns the loss.
Nr9  z,Adafactor does not support sparse gradients.ré   Úexp_avgr[  r\  Ú
exp_avg_sqr=  r(   r2  rÂ   )rQ  )Úalphar1  )rÉ   r3  r4  rS  rT  )rÖ   ÚgradÚdtyperY  Úfloat16Úbfloat16r*   Ú	is_sparseÚRuntimeErrorr
  ÚshaperH  rŸ   Ú
zeros_likeÚzerosÚtorN  rB  r?   ÚpowÚmul_Úadd_rU  r_  rX  Údiv_Úclamp_Úcopy_)r˜   ÚclosureÚlossrß   Úpre  r
  Ú
grad_shaperF  rG  Úp_data_fp32r[   Úbeta2tÚupdater[  r\  rc  rb  s   &&                r   ré   ÚAdafactor.step²  s  € ð ˆØÒÙ“9ˆDà×&Õ&ˆEØ˜8—_‘_�Ø—6‘6’>ÙØ—v‘v�Ø—:‘:¤%§-¡-´·±Ð!@Ô@ØŸ:™:›<�DØ—>—>�>Ü&Ð'UÓVÐVàŸ
™
 1��Ø!ŸZ™Z�
à-1×->Ñ->¸uÓ-QÑ*�ä�u“: ”?Ø$%�E˜&‘Mç'ä+0×+;Ò+;¸DÓ+A˜˜iÑ(ßÜ27·+²+¸jÈÈ"¸oÓ2N×2QÑ2QÐRVÓ2W˜Ð.Ñ/Ü27·+²+¸jÈÈ"¸oÐPZÐ[]Ð[^ÐP_Õ>_Ó2`×2cÑ2cÐdhÓ2i˜Ð.Ò/ä.3×.>Ò.>¸tÓ.D˜˜lÑ+à#$�E˜%’Lç'Ø+0°Õ+;×+>Ñ+>¸tÓ+D˜˜iÑ(ßØ27Ð8HÕ2I×2LÑ2LÈTÓ2R˜Ð.Ñ/Ø27Ð8HÕ2I×2LÑ2LÈTÓ2R˜Ð.Ò/à.3°LÕ.A×.DÑ.DÀTÓ.J˜˜lÑ+à�Ø—7‘7œuŸ}™}¬e¯n©nÐ=Ô=Ø"-×"3Ñ"3Ó"5�Kà�f— Õ"“Ø#Ÿy™y¨Ó5��e‘Ø—\‘\ %Ó/�àœtŸxšx¨¨f­°u¸\Õ7JÓKÕK�Ø �' U¨5¥\°!¥_Õ4�ßØ%*Ð+;Õ%<�NØ%*Ð+;Õ%<�Nà"×'Ñ'¨Ó/×4Ñ4°V·[±[ÀR°[Ó5HÐQTÐW]ÕQ]Ð4Ô_Ø"×'Ñ'¨Ó/×4Ñ4°V·[±[ÀR°[Ó5HÐQTÐW]ÕQ]Ð4Ô_ð "×1Ñ1°.ÓQ�FØ—K‘K Õ%à!& |Õ!4�Jà—O‘O FÓ+×0Ñ0°ÀÀfÅÐ0ÔNØ'×-Ñ-Ó/×4Ñ4°TÓ:�Fà—‘˜TŸY™Y vÓ.°Ð7GÕ1HÕH×PÑPÐUXÐPÓYÔZØ—‘˜B”ç#Ø# IÕ.�GØ—L‘L  w¥Ó0×5Ñ5°fÀQÈÈwÍÕEWÐ5ÔYØ$�Fà˜Õ(¨AÔ-Ø×$Ñ$ [ÀÕ:OÐ9OÐRTÕ9TÐ$ÔVà× Ñ  & Ô)à—7‘7œuŸ}™}¬e¯n©nÐ=×=Ø—G‘G˜K×(ôY %ñ 'ð^ ˆr   r   )	N)g ÂëþKH´9r  r(   gš™™™™™é¿Nr5   TTFr  )r²   r³   r´   rµ   r¶   r™   ÚstaticmethodrB  rH  rN  r_  rY  Úno_gradré   r·   Ú__classcell__©r:  s   @r   r/  r/  !  s{   ø† ñR÷h+ð> ñ)ó ð)ð ñ*ó ð*ð
 ñ8ó ð8ð ñ-ó ð-ð ‡]‚]ƒ_ó[ó ö[r   r/  c                  ó6   a € ] tR tRtRtRV 3R lltR tRtV ;t# )ÚAdafactorSchedulei  a(  
Since [`~optimization.Adafactor`] performs its own scheduling, if the training loop relies on a scheduler (e.g.,
for logging), this class creates a proxy object that retrieves the current lr values from the optimizer.

It returns `initial_lr` during startup and the actual `lr` during stepping.
c                	ó�   <a€ V3R  lpVP                    F  pSVR&   K
  	  \        SV `	  W4       VP                    F  pVR K  	  R# )c                ó   <€ S# r  r   )r   Ú
initial_lrs   &€r   r0   Ú-AdafactorSchedule.__init__.<locals>.lr_lambda  s	   ø€ ØÐr   r…  N)rÖ   r8  r™   )r˜   r   r…  r0   rß   r:  s   &&f  €r   r™   ÚAdafactorSchedule.__init__  sI   ù€ õ	ð ×+Ô+ˆEØ",ˆE�,Óñ ,ä‰Ñ˜Ô.Ø×+Ô+ˆEØ�lÒ#ó ,r   c           	     	ó.  € V P                   pVP                   Uu. uFQ  pVR ,          ^ ,          P                  f   K!  VP                  W!P                  VR ,          ^ ,          ,          4      NKS  	  pp\        V4      ^ 8X  d   V P                  pV# u upi )r9  )r   rÖ   re  rB  r
  rŸ   Úbase_lrs)r˜   Úoptrß   Úlrss   &   r   Úget_lrÚAdafactorSchedule.get_lr#  s‚   € Ø�n‰nˆð ×)Ò)ó
á)�Ø�X�˜qÕ!×&Ñ&ô >ˆC�K‰K˜Ÿy™y¨¨x­¸Õ);Õ<Ö=Ù)ð 	ð 
ô
 ˆs‹8�qŒ=Ø—-‘-ˆCØˆ
ùò
s
   ›B¾4Br   ©r5   )	r²   r³   r´   rµ   r¶   r™   rŒ  r·   r  r€  s   @r   r‚  r‚    s   ø† ñ÷$÷	ð 	r   r‚  c                ó   € \        W4      # )a4  
Get a proxy schedule for [`~optimization.Adafactor`]

Args:
    optimizer ([`~torch.optim.Optimizer`]):
        The optimizer for which to schedule the learning rate.
    initial_lr (`float`, *optional*, defaults to 0.0):
        Initial lr

Return:
    [`~optimization.Adafactor`] proxy schedule object.


)r‚  )r   r…  s   &&r   Úget_adafactor_scheduler�  /  s   € ô ˜YÓ3Ð3r   r  )rS  )r<   rS  )r   rS  )gH¯¼šò×z>r(   rS  )NrS  )r<   rS  NN)r<   rS  NNN)NNr„   r…   r  r<   rS  )NNNrŽ  )Ar¶   Ú
__future__r   r?   rŠ   Ú	functoolsr   Útypingr   rY  Útorch.optimr   Útorch.optim.lr_schedulerr   r   Útrainer_pt_utilsr   r	   Útrainer_utilsr
   Úutilsr   Ú
get_loggerr²   Úloggerr   r   r#   r,   r1   r6   r8   rD   rI   rL   rO   rY   r_   rf   ri   rt   rx   r{   r‡   rŒ   rŽ   r¹   r  ÚLINEARÚCOSINEÚCOSINE_WITH_RESTARTSÚ
POLYNOMIALr'  r*  r+  r(  ÚCOSINE_WITH_MIN_LRÚCOSINE_WARMUP_WITH_MIN_LRr,  r)  r#  r$  r/  r‚  r�  r   r   r   Ú<module>r¡     s¶  ðñ +å "ã Û Ý Ý ã Ý !ß @ç NÝ (Ý ð 
×	Ò	˜HÓ	%€ô÷Lõ"2õ$÷Aõ*uô6õ6Z÷6õD^÷6õBô*+6ð\Ðnr÷ ÷Að<Øru÷÷16ðhð ðð $(÷÷256õp#÷LF6÷R%.ñ %.÷Pp'ñ p'õf	)ð" ×ÑÐ9Ø×ÑÐ9Ø×&Ñ&Ð(ZØ×ÑÐGØ×ÑÐ1Ø×&Ñ&Ð(IØ×ÑÐ 9Ø×#Ñ#Ð%CØ×$Ñ$Ð&QØ×+Ñ+Ð-`Ø×%Ñ%Ð'7Ø×ÑÐ-ðÐ ÷ ^ôBm�	ô mô`˜ô ö<4r   