ó
    !Eñi=  ã            	       óD   • S SK Jr  S SKrS SKJr   S	S\S\S\S\4S jjrg)
é    )ÚAnyN)Ú_get_device_indexÚdeviceÚoptionalÚ	allow_cpuÚreturnc                 ó  • [        U [        5      (       a  U $ [        U [        5      (       a  [        R                  " U 5      n [        U [        R                  5      (       aD  U(       a  U R
                  S;  a  [        SU  35      eOU R
                  S:w  a  [        SU  35      e[        R                  R                  5       (       d5  [        U [        R                  R                  5      (       a  U R                  $ [        XU5      $ )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``.
)ÚmtiaÚcpuz(Expected a mtia or cpu device, but got: r
   z!Expected a mtia device, but got: )Ú
isinstanceÚintÚstrÚtorchr   ÚtypeÚ
ValueErrorÚjitÚis_scriptingr
   ÚidxÚ_torch_get_device_index)r   r   r   s      ÚN/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/mtia/_utils.pyr   r   	   sÉ   € ô  �&œ#×ÑØˆÜ�&œ#×ÑÜ—’˜fÓ%ˆÜ�&œ%Ÿ,™,×'Ñ'ÞØ�{‰{ /Ó1Ü Ð#KÈFÈ8Ð!TÓUÐUð 2à�[‰[˜FÓ"ÜÐ@ÀÀÐIÓJÐJÜ�9‰9×!Ñ!×#Ñ#Ü�fœeŸj™j×/Ñ/×0Ñ0Ø—:‘:ÐÜ" 6°YÓ?Ð?ó    )FF)Útypingr   r   Útorch._utilsr   r   Úboolr   © r   r   Ú<module>r      sA   ðÝ ã õ Fð <Añ@Øð@Øð@Ø48ð@àö@r   