
    JTh=              	       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      I/var/www/auris/envauris/lib/python3.13/site-packages/torch/mtia/_utils.pyr   r   	   s      &#&#f%&%,,''{{/1 #KF8!TUU 2[[F"@IJJ99!!##fejj//00::"6Y??    )FF)typingr   r   torch._utilsr   r   boolr    r   r   <module>r      sA      F <A@@@48@@r   