§
    �Štjx  ã            	       ó6   — d dl mZ d dlZ	 d	dedededefd„ZdS )
é    )ÚAnyNFÚdeviceÚoptionalÚ	allow_cpuÚreturnc                 ó�  — | € |rt           j                             ¦   «         S t          | t          ¦  «        r| S t           j                             ¦   «         s&t          | t           j        j        ¦  «        r| j	        S t          | t          ¦  «        rt          j        | ¦  «        } d}t          | t           j        ¦  «        rN|s| j        dk    rt          d| › �¦  «        ‚| j        dvrt          d| › �¦  «        ‚| j        dk    rdn| j        }|€3|rt           j                             ¦   «         }n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       úO/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/mtia/_utils.pyÚ_get_device_indexr      sX  € ð" €~˜(€~åŒx×'Ò'Ñ)Ô)Ð)Ý�&�#ÑÔð ØˆÝŒ9×!Ò!Ñ#Ô#ð Ý�f�eœjÔ/Ñ0Ô0ð 	Ø”:ÐÝ�&�#ÑÔð &Ý”˜fÑ%Ô%ˆØ!€JÝ�&�%œ,Ñ'Ô'ð BØð 	N˜Vœ[¨EÒ1Ð1ÝÐLÀFÐLÐLÑMÔMÐMØŒ;˜oÐ-Ð-ÝÐPÈÐPÐPÑQÔQÐQØ!œ;¨%Ò/Ð/�R�R°V´\ˆ
ØÐØð 	Ýœ×1Ò1Ñ3Ô3ˆJˆJåØbÐZ`ÐbÐbñô ð ð Ðó    )FF)Útypingr   r   Úboolr   r   © r   r   ú<module>r      si   ðØ Ð Ð Ð Ð Ð à €€€ð <Að)ð )Øð)Øð)Ø48ð)àð)ð )ð )ð )ð )ð )r   