a
    þdS  ã                   @   st   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ ee eddœd	d
„Zeeddœdd„ZdS )é    )ÚIterable)Úapply_to_collection)ÚTensor)Ú	Optimizer)Úmove_data_to_device)Ú_DEVICEN)Ú
optimizersÚdeviceÚreturnc                 C   s   | D ]}t ||ƒ qdS )zBMoves optimizer states for a sequence of optimizers to the device.N)Ú_optimizer_to_device)r   r	   Úopt© r   úm/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/lightning_fabric/utilities/optimizer.pyÚ_optimizers_to_device   s    r   )Ú	optimizerr	   r
   c                 C   s,   | j  ¡ D ]\}}t|tt|ƒ| j |< q
dS )z4Moves the state of a single optimizer to the device.N)ÚstateÚitemsr   r   r   )r   r	   ÚpÚvr   r   r   r      s    r   )Útypingr   Z#lightning_utilities.core.apply_funcr   Ztorchr   Ztorch.optimr   Z%lightning_fabric.utilities.apply_funcr   Z lightning_fabric.utilities.typesr   r   r   r   r   r   r   Ú<module>   s   