Ë
      çi†  ã                   óf   — d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	  G d„ de
«      Zdeded	d
fd„Zy
)é    )ÚAnyÚCallableÚOptional)Úoverride)ÚMisconfigurationException)Ú_register_classesc                   ó’   — e Zd ZdZ	 	 	 ddedee   dedededefd	„Z	e
dded
ee   defd„«       Zdeddfd„Zdee   fd„Zdefd„Zy)Ú_AcceleratorRegistryad  This class is a Registry that stores information about the Accelerators.

    The Accelerators are mapped to strings. These strings are names that identify
    an accelerator, e.g., "gpu". It also returns Optional description and
    parameters to initialize the Accelerator, which were defined during the
    registration.

    The motivation for having a AcceleratorRegistry is to make it convenient
    for the Users to try different accelerators by passing mapped aliases
    to the accelerator flag to the Trainer.

    Example::

        @AcceleratorRegistry.register("sota", description="Custom sota accelerator", a=1, b=True)
        class SOTAAccelerator(Accelerator):
            def __init__(self, a, b):
                ...

        or

        AcceleratorRegistry.register("sota", SOTAAccelerator, description="Custom sota accelerator", a=1, b=True)

    NÚnameÚacceleratorÚdescriptionr   Úinit_paramsÚreturnc                 óÊ   ‡ ‡‡— ‰�t        ‰t        «      st        d‰› �«      ‚‰‰ v r|st        d‰› d�«      ‚i Š|‰d<   |‰d<   dt        dt        fˆˆˆ fd„}|� ||«      S |S )	aˆ  Registers a accelerator mapped to a name and with required metadata.

        Args:
            name : the name that identifies a accelerator, e.g. "gpu"
            accelerator : accelerator class
            description : accelerator description
            override : overrides the registered accelerator, if True
            init_params: parameters to initialize the accelerator

        z`name` must be a str, found Ú'z@' is already present in the registry. HINT: Use `override=True`.r   r   r   r   c                 ó&   •— | ‰d<   ‰‰d<   ‰‰‰<   | S )Nr   Úaccelerator_name© )r   Údatar   Úselfs    €€€ú{/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/lightning_fabric/accelerators/registry.pyÚdo_registerz2_AcceleratorRegistry.register.<locals>.do_registerL   s'   ø€ Ø"-ˆD�ÑØ'+ˆDÐ#Ñ$ØˆD�‰JØÐó    )Ú
isinstanceÚstrÚ	TypeErrorr   r   )r   r   r   r   r   r   r   r   s   ``     @r   Úregisterz_AcceleratorRegistry.register/   s‰   ú€ ð$ �¤
¨4´Ô 5ÜÐ:¸4¸&ÐAÓBÐBà�4‰<¡Ü+¨a°¨vÐ5uÐ,vÓwÐwà!ˆà)ˆˆ]ÑØ)ˆˆ]Ñð	¤Xð 	´(÷ 	ð Ð"Ù˜{Ó+Ð+àÐr   Údefaultc                 ó’   — || v r| |   } |d   di |d   ¤ŽS |�|S d}| j                  «       }t        |j                  ||«      «      ‚)zÅCalls the registered accelerator with the required parameters and returns the accelerator object.

        Args:
            name (str): the name that identifies a accelerator, e.g. "gpu"

        r   r   z/'{}' not found in registry. Available names: {}r   )Úavailable_acceleratorsÚKeyErrorÚformat)r   r   r   r   Úerr_msgÚavailable_namess         r   Úgetz_AcceleratorRegistry.getW   sb   € ð �4‰<Ø˜‘:ˆDØ&�4˜Ñ&Ñ=¨¨mÑ)<Ñ=Ð=àÐØˆNàCˆØ×5Ñ5Ó7ˆÜ�w—~‘~ d¨OÓ<Ó=Ð=r   c                 ó&   — | j                  |«       y)z+Removes the registered accelerator by name.N)Úpop)r   r   s     r   Úremovez_AcceleratorRegistry.removej   s   € à�‰��r   c                 ó4   — t        | j                  «       «      S )z)Returns a set of registered accelerators.)ÚsetÚkeys©r   s    r   r    z+_AcceleratorRegistry.available_acceleratorsn   s   € ä�4—9‘9“;ÓÐr   c                 ó^   — dj                  dj                  | j                  «       «      «      S )NzRegistered Accelerators: {}z, )r"   Újoinr    r,   s    r   Ú__str__z_AcceleratorRegistry.__str__r   s%   € Ø,×3Ñ3°D·I±I¸d×>YÑ>YÓ>[Ó4\Ó]Ð]r   )NÚ F)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úboolr   r   r   r%   r(   r*   r    r/   r   r   r   r
   r
      sµ   „ ñð6 +/ØØñ&àð&ð ˜hÑ'ð&ð ð	&ð
 ð&ð ð&ð 
ó&ðP ñ>˜ð > h¨s¡mð >¸sò >ó ð>ð$˜3ð  4ó ð ¨¨C©ó  ð^˜ô ^r   r
   ÚregistryÚbase_moduler   Nc                 óV   — ddl }|j                  |«      }ddlm} t	        | d||«       y)zLegacy.

    Do not use.

    r   N)ÚAcceleratorÚregister_accelerators)Ú	importlibÚimport_moduleÚ)lightning_fabric.accelerators.acceleratorr9   r   )r6   r7   r;   Úmoduler9   s        r   Úcall_register_acceleratorsr?   v   s)   € ó à×$Ñ$ [Ó1€FÝEä�hÐ 7¸ÀÕMr   )Útypingr   r   r   Útyping_extensionsr   Ú%lightning_fabric.utilities.exceptionsr   Ú#lightning_fabric.utilities.registryr   Údictr
   r   r?   r   r   r   Ú<module>rE      sG   ð÷ +Ñ *å &å KÝ Aô]^˜4ô ]^ð@NÐ)=ð NÈCð NÐTXô Nr   