a
    h                     @   s8   d dl mZ d dlZd dlmZ deeedddZdS )	    )OptionalN)DeviceF)deviceoptionalreturnc                 C   s   t | tr| S t | tr"t| } d }t | tjrttj }|d u rLtd|j| jkrnt	| j d| d| j
}|d u r|st	d|  t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   ZacceleratorZcurrent_acceleratorRuntimeErrortype
ValueErrorindexZcurrent_device_index)r   r   Zdevice_indexacc r   F/var/www/auris/lib/python3.9/site-packages/torch/accelerator/_utils.py_get_device_index   s*    




r   )F)	typingr   r   Ztorch.typesr   Z	_device_tboolr	   r   r   r   r   r   <module>   s   