
    קg                         U d dl mZmZmZ d dlZd dlmc mZ d dlm	Z	 g Z
ee         ed<   ej        j         G d d                      ZdS )    )DictListOptionalN)Tensor__all__c                       e Zd Z	 	 	 	 	 	 	 	 	 ddee         deded	ed
edededededefdZdeee                  fdZ	dS )_FunctionalRMSprop{Gz?Gz?:0yE>        Fparamslralphaepsweight_decaymomentumcenteredforeachmaximize_allow_empty_param_listc                 T   |||||d| _         || _        || _        |	| _        t	          |          dk    r|
st          d          d|i| _        t          j        	                    t          t          j        t          t          t          j        f         f         i           | _        d S )N)r   r   r   r   r   r   z%optimizer got an empty parameter listr   )defaultsr   r   r   len
ValueErrorparam_grouptorchjitannotater   r   strstate)selfr   r   r   r   r   r   r   r   r   r   s              f/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/distributed/optim/functional_rmsprop.py__init__z_FunctionalRMSprop.__init__   s     ( 
 
 ! v;;!$;DEEE %f-Y''U\4U\@Q;R-R(SUWXX


    	gradientsc                 D   | j         d         }g }g }g }g }g }g }| j        d         }	| j        d         }
| j        d         }| j        d         }| j        d         }t          |          t          |          k    r6t          ddt          |           d	z   d
t          |           z             d}t	          ||          D ]}\  }}|t|t          j        |          z  }|                    |           |                    |           || j        vri | j        |<   | j        |         }t          j	        d          |d<   t          j
        |t
          j                  |d<   |dk    r#t          j
        |t
          j                  |d<   | j        r#t          j
        |t
          j                  |d<   | j        |         }|                    |d                    |dk    r|                    |d                    | j        r|                    |d                    |                    |d                    t          j                    5  t          j        |||||||	|
|||| j        | j        | j        |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   r   zEthe gradients passed in does not equal to the size of the parameters!zParams length: z. zGradients length: Fr   step)memory_format
square_avgr   momentum_buffergrad_avg)	r   r   r   r   r   r   r   r   has_complex)r   r   r   r   zipr   
is_complexappendr!   tensor
zeros_likepreserve_formatr   no_gradFrmspropr   r   )r"   r&   r   params_with_gradgradssquare_avgs	grad_avgsmomentum_buffer_liststate_stepsr   r   r   r   r   r-   paramgradientr!   s                     r#   r(   z_FunctionalRMSprop.step8   s)   !(+	!]4 g&mE"=,}^4v;;#i..((W3CKK33347s9~~778   "6955 	2 	2OE8#u/666 ''...X&&&
**(*DJu% Ju-E$)L$5$5E&M*/*:U-B+ + +E,'  !||383C!1F4 4 4/0 } ,1,<!1F- - -j) 
5)""5#6777a<<(//6G0HIII= 8$$U:%6777""5=111]__ 	 	I $)!'   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   3JJJN)	r
   r   r   r   r   FFFF)
__name__
__module____qualname__r   r   floatboolr$   r   r(    r%   r#   r	   r	      s        
 !(-Y YVY Y 	Y
 Y Y Y Y Y Y "&Y Y Y YBFd8F#34 F F F F F Fr%   r	   )typingr   r   r   r   torch.optim._functionaloptim_functionalr5   r   r   r    __annotations__r   scriptr	   rD   r%   r#   <module>rK      s    ' ' ' ' ' ' ' ' ' ' '  # # # # # # # # #       c    h h h h h h h h h hr%   