
    rh                     :    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                        rkt        j
                  j                         }|t        d      |j                  | j                  k7  rt        | j                   d| 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       k/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/torch/accelerator/_utils.py_get_device_indexr      s    &#&#f%"&L&%,,'335;56688v{{";;-Fse1M  ||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   