Ë
    S²j|  ã            	       ó4   — d dl mZ d dlZ	 ddedededefd„Zy)	é    )ÚAnyNÚdeviceÚoptionalÚ	allow_cpuÚreturnc                 ó   — | € |rt         j                  j                  «       S t        | t        «      r| S t         j
                  j                  «       s0t        | t         j                  j                  «      r| j                  S t        | t        «      rt        j                  | «      } d}t        | t         j                  «      rX|s| j                  dk(  rt        d| › �«      ‚| j                  dvrt        d| › �«      ‚| j                  dk(  rdn| j                  }|€0|r t         j                  j                  «       }|S t        d| › �«      ‚|S )a±  Get the device index from :attr:`device`, which can be a torch.device object, a Python integer, or ``None``.

    If :attr:`device` is a torch.device object, returns the device index if it
    is a MTIA device. Note that for a MTIA device without a specified index,
    i.e., ``torch.device('mtia')``, this will return the current default MTIA
    device if :attr:`optional` is ``True``. If :attr:`allow_cpu` is ``True``,
    CPU devices will be accepted and ``-1`` will be returned in this case.

    If :attr:`device` is a Python integer, it is returned as is.

    If :attr:`device` is ``None``, this will return the current default MTIA
    device if :attr:`optional` is ``True``.
    NÚcpuz$Expected a non cpu device, but got: )Úmtiar	   z(Expected a mtia or cpu device, but got: éÿÿÿÿzGExpected a torch.device with a specified index or an integer, but got: )ÚtorchÚ_CÚ_mtia_getDeviceÚ
isinstanceÚintÚjitÚis_scriptingr
   r   ÚidxÚstrÚtypeÚ
ValueErrorÚindex)r   r   r   Ú
device_idxs       úP/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/torch/mtia/_utils.pyÚ_get_device_indexr      s"  € ð" €~™(ä�x‰x×'Ñ'Ó)Ð)Ü�&œ#ÔØˆÜ�9‰9×!Ñ!Ô#Ü�fœeŸj™j×/Ñ/Ô0Ø—:‘:ÐÜ�&œ#ÔÜ—‘˜fÓ%ˆØ!€JÜ�&œ%Ÿ,™,Ô'Ù˜VŸ[™[¨EÒ1ÜÐCÀFÀ8ÐLÓMÐMØ�;‰;˜oÑ-ÜÐGÈÀxÐPÓQÐQØ!Ÿ;™;¨%Ò/‘R°V·\±\ˆ
ØÐÙÜŸ™×1Ñ1Ó3ˆJð
 Ðô ØYÐZ`ÐYaÐbóð ð Ðó    )FF)Útypingr   r   Úboolr   r   © r   r   ú<module>r      s6   ðÝ ã ð <Añ)Øð)Øð)Ø48ð)àô)r   