
    PhI              	       P    d dl mZ d dlZd dlmZ 	 ddedededefdZd	ede	fd
Z
y)    )AnyN)_get_device_indexdeviceoptional	allow_cpureturnc                    t        | t              r| S t        | t              rt        j                  |       } t        | t        j                        r;|r| j
                  dvr+t        d|        | j
                  dk7  rt        d|        t        j                  j                         s0t        | t        j                  j                        r| j                  S t        | ||      S )a  Get 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 CUDA device. Note that for a CUDA device without a specified index,
    i.e., ``torch.device('cuda')``, this will return the current default CUDA
    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 CUDA
    device if :attr:`optional` is ``True``.
    )cudacpuz(Expected a cuda or cpu device, but got: r
   z!Expected a cuda device, but got: )
isinstanceintstrtorchr   type
ValueErrorjitis_scriptingr
   idx_torch_get_device_index)r   r   r   s      \C:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\torch/cuda/_utils.pyr   r   	   s      &#&#f%&%,,'{{/1 #KF8!TUU[[F"@IJJ99!!#fejj//0::"68Y??    namec                 X    dt         fd}t        | t        f |d       |d      d      S )Nis_initc                       fd}|S )Nc                 j    r| j                   j                  }n| j                  }t        d|       )Nz&Tried to instantiate dummy base class )	__class____name__RuntimeError)objargskwargs
class_namer   s       r   err_fnz/_dummy_type.<locals>.get_err_fn.<locals>.err_fn+   s1     ]]33
 \\
!G
|TUUr    )r   r$   s   ` r   
get_err_fnz_dummy_type.<locals>.get_err_fn*   s    	V r   TF)__init____new__)boolr   object)r   r&   s     r   _dummy_typer+   )   s5    D  vij&6:eCTU r   )FF)typingr   r   torch._utilsr   r   r)   r   r   r   r+   r%   r   r   <module>r.      sU      F <A@@@48@@@c d r   