o
    Ih                     @   s<   d dl mZ d dlZd dlmZ d
dededefdd	ZdS )    )OptionalN)DeviceFdeviceoptionalreturnc                 C   s   t | tr| S t | trt| } d }t | tjr=tj }|d u r&td|j| jkr:t	| j dtj  d| j
}|d u rO|sJt	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   acceleratorcurrent_acceleratorRuntimeErrortype
ValueErrorindexcurrent_device_index)r   r   device_indexacc r   L/var/www/vscode/kcb/lib/python3.10/site-packages/torch/accelerator/_utils.py_get_device_index   s*   




r   )F)	typingr   r   torch.typesr   	_device_tboolr	   r   r   r   r   r   <module>   s    