
    3j|              	       8    S SK Jr  S SKr SS\S\S\S\4S jjrg)	    )AnyNdeviceoptional	allow_cpureturnc                    U c%  U(       a  [         R                  R                  5       $ [        U [        5      (       a  U $ [         R
                  R                  5       (       d5  [        U [         R                  R                  5      (       a  U R                  $ [        U [        5      (       a  [         R                  " U 5      n Sn[        U [         R                  5      (       aa  U(       d  U R                  S:X  a  [        SU  35      eU R                  S;  a  [        SU  35      eU R                  S:X  a  SOU R                  nUc5  U(       a   [         R                  R                  5       nU$ [        SU  35      eU$ )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       K/home/wildlama/miniconda3/lib/python3.13/site-packages/torch/mtia/_utils.py_get_device_indexr      s1   " ~(xx''))&#99!!##fejj//00::&#f%!J&%,,''V[[E1CF8LMM;;o-GxPQQ!;;%/RV\\
113J
  YZ`Yab      )FF)typingr   r   boolr   r    r   r   <module>r      s6      <A)))48))r   