§
    ŠŠtjÁ  ã                   ó(   — d dl Z  G d„ d¦  «        ZdS )é    Nc                   ó�   — e Zd ZdZdeej        z  fd„Zed„ ¦   «         Z	dedz  fd„Z
dedz  fd„Zdej        fd	„Zd
„ Zd„ Zd„ ZdS )Ú_remote_devicea@  
    Represents a device on a remote worker.

    Args:
        remote_device (str or torch.device): Represents a device on a remote worker.
            The string format should be one of the following:

                1. "<workername>/<device>", where the device field can be parsed as torch.device type.
                   E.g., "trainer0/cpu", "trainer0", "ps0/cuda:0".
                   In addition, the device field can be optional and the default value is "cpu".
                2. "rank:<rank>/<device>", where <rank> is the rank of the
                   process and device can be parsed as torch.device type.
                   E.g., "rank:0/cpu", "rank:0", "rank:0/cuda:0"
                3. <workername> and <rank> are optional and formats like "cpu"
                    and "cuda:1", just represent local devices.
    Úremote_devicec                 óø  — d|› d�}d | _         d | _        d | _        t          |t          j        ¦  «        r|| _        nÑt          |t          ¦  «        r�|                     d¦  «        }t          |¦  «        dk    r|\  | _         | _        n„t          |¦  «        dk    rCt           
                    |d         ¦  «        r|d         | _        nC|d         | _         d| _        n.t          |¦  «        ‚t          dt          |¦  «        › �¦  «        ‚| j         �| j         st          |¦  «        ‚t	          j        | j        ¦  «        | _        | j         �§| j                              d	¦  «        }t          |¦  «        dk    rX|d         d
k    r=|d                              ¦   «         r#t          |d         ¦  «        | _        d | _         d S t          |¦  «        ‚t          |¦  «        dk    rt          |¦  «        ‚d S d S )NzCould not parse remote_device: zU. The valid format is '<workername>/<device>' or 'rank:<rank>/<device>' or '<device>'ú/é   é   r   Úcpuz Invalid type for remote_device: ú:Úrank)Ú_worker_nameÚ_rankÚ_deviceÚ
isinstanceÚtorchÚdeviceÚstrÚsplitÚlenr   Ú_is_valid_local_deviceÚ
ValueErrorÚ	TypeErrorÚtypeÚisdigitÚint)Úselfr   ÚPARSE_ERRORÚfieldss       ú]/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/distributed/remote_device.pyÚ__init__z_remote_device.__init__   sþ  € ðN¨mð Nð Nð Nð 	ð !ˆÔØˆŒ
Ø8<ˆŒå�m¥U¤\Ñ2Ô2ð 	VØ(ˆDŒLˆLÝ˜¥sÑ+Ô+ð 	VØ"×(Ò(¨Ñ-Ô-ˆFÝ�6‰{Œ{˜aÒÐØ28Ñ/�Ô! 4¤< <Ý�V‘” Ò!Ð!å!×8Ò8¸À¼ÑCÔCð )Ø#)¨!¤9�D”L�Là(.¨q¬	�DÔ%Ø#(�D”L�Lå  Ñ-Ô-Ð-åÐT½tÀMÑ?RÔ?RÐTÐTÑUÔUÐUð ÔÐ(°Ô1BÐ(Ý˜[Ñ)Ô)Ð)õ ”| D¤LÑ1Ô1ˆŒð ÔÐ(ØÔ&×,Ò,¨SÑ1Ô1ˆFÝ�6‰{Œ{˜aÒÐà˜!”9 Ò&Ð&¨6°!¬9×+<Ò+<Ñ+>Ô+>Ð&Ý!$ V¨A¤Y¡¤�D”JØ(,�DÔ%Ð%Ð%å$ [Ñ1Ô1Ð1Ý�V‘”˜q’�Ý  Ñ-Ô-Ð-ð )Ð(ð !�ó    c                 óR   — 	 t          j        | ¦  «         dS # t          $ r Y dS w xY w)NTF)r   r   Ú	Exception)r   s    r   r   z%_remote_device._is_valid_local_deviceG   s>   € ð	ÝŒL˜Ñ Ô Ð Ø�4øÝð 	ð 	ð 	Ø�5�5ð	øøøs   ‚ ˜
&¥&ÚreturnNc                 ó   — | j         S )zlReturn the name of remote worker representing the remote device and ``None`` if no worker name is available.)r   ©r   s    r   Úworker_namez_remote_device.worker_nameP   s   € àÔ Ð r!   c                 ó   — | j         S )z…
        Returns the rank of remote worker representing the remote device.
        Returns ``None`` if no rank is available.
        )r   r&   s    r   r   z_remote_device.rankT   s   € ð
 ŒzÐr!   c                 ó   — | j         S )z-Return the local device on the remote worker.)r   r&   s    r   r   z_remote_device.device[   s
   € àŒ|Ðr!   c                 óô   — | j         �E| j        �| j        › d| j         › �S | j        �d| j        › d| j         › �S t          | j         ¦  «        S | j        �| j        › S | j        �| j        › S t	          d¦  «        ‚)Nr   zrank:zInvalid state!)r   r   r   r   ÚRuntimeErrorr&   s    r   Ú__repr__z_remote_device.__repr___   s”   € ØŒ<Ð#ØÔ Ð,ØÔ+Ð<Ð<¨d¬lÐ<Ð<Ð<Ø”Ð'Ø:˜tœzÐ:Ð:¨D¬LÐ:Ð:Ð:å˜4œ<Ñ(Ô(Ð(àÔ Ð,ØÔ+Ð-Ð-Ø”Ð'Øœ*�Ð&å"Ð#3Ñ4Ô4Ð4r!   c                 óŒ   — t          |t          ¦  «        o/| j        |j        k    o| j        |j        k    o| j        |j        k    S ©N)r   r   r   r   r   )r   Úothers     r   Ú__eq__z_remote_device.__eq__o   sI   € Ý˜%¥Ñ0Ô0ð 
ØÔ Ô!3Ò3ð *Ø” ¤Ò-ð*à”
˜eœkÒ)ð	
r!   c                 ó~   — t          | j        ¦  «        t          | j        ¦  «        z  t          | j        ¦  «        z  S r.   )Úhashr   r   r   r&   s    r   Ú__hash__z_remote_device.__hash__v   s1   € Ý�DÔ%Ñ&Ô&­¨d¬lÑ);Ô);Ñ;½dÀ4Ä:Ñ>NÔ>NÑNÐNr!   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r    Ústaticmethodr   r'   r   r   r,   r0   r3   © r!   r   r   r      sé   € € € € € ðð ð"-. c¨E¬LÑ&8ð -.ð -.ð -.ð -.ð^ ðð ñ „\ðð!˜S 4™Zð !ð !ð !ð !ð�c˜D‘jð ð ð ð ð˜œð ð ð ð ð5ð 5ð 5ð 
ð 
ð 
ðOð Oð Oð Oð Or!   r   )r   r   r9   r!   r   ú<module>r:      sV   ðð €€€ðqOð qOð qOð qOð qOñ qOô qOð qOð qOð qOr!   