o
    ei                     @   s4   d Z ddlZddlZddlZdZdd Zdd ZdS )zTThis module implements some workarounds for dependencies

Authors
 * Aku Rouhe 2022
    NWEAKREFc                 C   s.   |   }|dd urt|d< t|| d S )N_scale_fn_ref)
state_dictgetWEAKREF_MARKERtorchsave)objpathr    r   \/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/speechbrain/utils/_workarounds.py_cycliclrsaver   s   r   c              	   C   s   ~d}t j||d}|dtkr+t| jtjs+d}|d7 }|d7 }|d7 }t	| z| j
t j||ddd	 W d S  tyN   | 
t j||d Y d S w )
Ncpu)map_locationr   zKLoading CyclicLR scheduler and the _scale_ref_fn did not exist in instance.zB You did not construct it with the same parameters it was created!z+ Looks like you changed the scale function!zE If this was not intentional, the scheduler might not work correctly.T)strict)r   loadr   r   
isinstancer   weakref
WeakMethodwarningswarnload_state_dict	TypeError)r	   r
   end_of_epochdevicer   MSGr   r   r   _cycliclrloader   s   
r   )__doc__r   r   r   r   r   r   r   r   r   r   <module>   s    