
    Vh                     :    d dl mZ d dlZd dlmZ ddededefdZy)	    )OptionalN)Devicedeviceoptionalreturnc                    t        | t              r| S t        | t              rt        j                  |       } d }t        | t        j                        rt        j
                  j                         }|t        d      |j                  | j                  k7  r7t        | j                   dt        j
                  j                          d      | j                  }|.|st        d|        t        j
                  j                         S |S )NzAccelerator expectedz' doesn't match the current accelerator .zFExpected a torch.device with a specified index or an integer, but got:)
isinstanceintstrtorchr   acceleratorcurrent_acceleratorRuntimeErrortype
ValueErrorindexcurrent_device_index)r   r   device_indexaccs       H/home/dcms/DCMS/lib/python3.12/site-packages/torch/accelerator/_utils.py_get_device_indexr      s    &#&#f%"&L&%,,'335;56688v{{";;-FuGXGXGlGlGnFoopq  ||XY_X`a    5577    )F)	typingr   r   torch.typesr   	_device_tboolr   r    r   r   <module>r      s(      +i 4 C r   