
    [Th                     0    S SK JrJr  S SKr " S S5      rg)    )OptionalUnionNc                       \ rS rSrSrS\\\R                  4   4S jr	\
S 5       rS\\   4S jrS\\   4S jrS\R                  4S	 jrS
 rS rS rSrg)_remote_device   a  
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                    SU S3nS U l         S U l        S U l        [        U[        R
                  5      (       a  Xl        O[        U[        5      (       a  UR                  S5      n[        U5      S:X  a  Uu  U l         U l        Ok[        U5      S:X  a:  [        R                  US   5      (       a  US   U l        O4US   U l         SU l        O"[        U5      e[        S[        U5       35      eU R                   b  U R                   (       d  [        U5      e[        R
                  " U R                  5      U l        U R                   b  U R                   R                  S	5      n[        U5      S:X  aG  US   S
:X  a3  US   R                  5       (       a  [        US   5      U l        S U l         g [        U5      e[        U5      S:  a  [        U5      eg g )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       W/var/www/auris/envauris/lib/python3.13/site-packages/torch/distributed/remote_device.py__init___remote_device.__init__   s   -m_ =N N 	 !
@DmU\\22(Ls++"((-F6{a28/!4<V!!88CC#)!9DL(.q	D%#(DL -->tM?R>STUU (1B1B[)) ||DLL1 (&&,,S1F6{a!9&6!9+<+<+>+>!$VAYDJ(,D%$[11Vq -- ! )    c                 R     [         R                  " U 5        g! [         a     gf = f)NTF)r   r   	Exception)r   s    r"   r   %_remote_device._is_valid_local_deviceH   s(    	LL  		s    
&&returnc                     U R                   $ )zlReturn the name of remote worker representing the remote device and ``None`` if no worker name is available.)r   r   s    r"   worker_name_remote_device.worker_nameQ   s       r%   c                     U R                   $ )zm
Returns the rank of remote worker representing the remote device.
Returns ``None`` if no rank is available.
)r   r+   s    r"   r   _remote_device.rankU   s    
 zzr%   c                     U R                   $ )z-Return the local device on the remote worker.)r   r+   s    r"   r   _remote_device.device\   s    ||r%   c                 f   U R                   bf  U R                  b  U R                   SU R                    3$ U R                  b  SU R                   SU R                    3$ [        U R                   5      $ U R                  b  U R                   $ U R                  b  U R                   $ [	        S5      e)Nr
   zrank:zInvalid state!)r   r   r   r   RuntimeErrorr+   s    r"   __repr___remote_device.__repr__`   s    <<#  ,++,Adll^<<'tzzl!DLL>::4<<((  ,++,-'**&"#344r%   c                     [        U[        5      =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ N)r   r   r   r   r   )r   others     r"   __eq___remote_device.__eq__p   sT    %0 
!3!33 *-*

ekk)	
r%   c                     [        U R                  5      [        U R                  5      -  [        U R                  5      -  $ r7   )hashr   r   r   r+   s    r"   __hash___remote_device.__hash__w   s/    D%%&dll);;d4::>NNNr%   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r#   staticmethodr   r   r,   r   r   r4   r9   r=   __static_attributes__ r%   r"   r   r      sv    "-.eC,=&> -.^  !Xc] !hsm  5 
Or%   r   )typingr   r   r   r   rF   r%   r"   <module>rH      s    " qO qOr%   