L i= @ddlmZddlZddlmZ d dedededefdZy) )AnyN)_get_device_indexdeviceoptional allow_cpureturnct|tr|St|trtj|}t|tjr;|r|j dvr+t d||j dk7rt d|tjjs0t|tjjr |jSt|||S)aGet 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``. )mtiacpuz(Expected a mtia or cpu device, but got: r z!Expected a mtia device, but got: ) isinstanceintstrtorchrtype ValueErrorjit is_scriptingr idx_torch_get_device_index)rrrs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/mtia/_utils.pyrr s &# &#f%&%,,' {{/1 #KF8!TUU [[F "@IJ J 99 ! ! # fejj// 0::  "68Y ??)FF)typingrr torch._utilsrrboolr rrrsA F