
    Ph                     n   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZ 	 d dlZedefd       ZdefdZd	eddfd
ZdefdZdeddfdZdefdZddZedd       Z G d de      Z ee j6                  e   e      e j6                  e<    e       rdnda e       rdayday# e$ r dZY w xY w)    N)contextmanager)	lru_cache)Any)__allow_nonbracketed_mutationContextProp
PropModulereturnc                      t         duS )z>Return a bool indicating if opt_einsum is currently available.N_opt_einsum     mC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\torch/backends/opt_einsum/__init__.pyis_availabler      s     d""r   c                      t         S )zNReturn the opt_einsum package if opt_einsum is currently available, else None.r   r   r   r   get_opt_einsumr      s    r   _enabledc                 >    t               s| rt        d|  d      | ay )Nz5opt_einsum is not available, so setting `enabled` to z will not reap the benefits of calculating an optimal path for einsum. torch.einsum will fall back to contracting from left to right. To enable this optimal path calculation, please install opt-einsum.)r   
ValueErrorenabled)r   s    r   _set_enabledr      s/    >hCH: N6 6
 	
 Gr   c                      t         S N)r   r   r   r   _get_enabledr   &   s    Nr   	_strategyc                     t               st        d|  d      t        st        d|  d      | dvrt        d|        | ay )Nz6opt_einsum is not available, so setting `strategy` to z will not be meaningful. torch.einsum will bypass path calculation and simply contract from left to right. Please install opt_einsum or unset `strategy`.z6opt_einsum is not enabled, so setting a `strategy` to z will not be meaningful. torch.einsum will bypass path calculation and simply contract from left to right. Please set `enabled` to `True` as well or unset `strategy`.)autogreedyoptimalzH`strategy` must be one of the following: [auto, greedy, optimal] but is )r   r   r   strategy)r   s    r   _set_strategyr!   *   sw    >DYK P= =
 	

 DYK PJ J
 	

 55VW`Vab
 	
 Hr   c                      t         S r   )r    r   r   r   _get_strategyr#   ?   s    Or   c                 j    t         t               sd nt        f}| t        |        |t	        |       |S r   )r   r   r    r   r!   )r   r   
orig_flagss      r   	set_flagsr&   C   s4    |~48DJXi r   c              #     K   t               5  t        | |      }d d d        	 d  t               5  t          d d d        y # 1 sw Y   *xY w# 1 sw Y   y xY w# t               5  t          d d d        w # 1 sw Y   w xY wxY wwr   )r   r&   )r   r    r%   s      r   flagsr(   L   sh     	&	(w1
 
)# +,z" -, 
)	( -,*,z" -,,s_   BABA 
B	A	BABABB&	A8/	B8B=BBc                   \     e Zd Z fdZ eee      ada e	       r ee
e      a xZS  xZS )OptEinsumModulec                 &    t         |   ||       y r   )super__init__)selfmname	__class__s      r   r-   zOptEinsumModule.__init__^   s    D!r   N)__name__
__module____qualname__r-   r   r   r   r   r    r   r#   r!   __classcell__)r1   s   @r   r*   r*   ]   s1    " ,5GH~}m< r   r*   TFr   )NN)syswarnings
contextlibr   	functoolsr   
_lru_cachetypingr   torch.backendsr   r   r   
opt_einsumr   ImportErrorboolr   r   r   r   strr!   r#   r&   r(   r*   modulesr2   r   r    r   r   r   <module>rB      s    
  % -  Q Q$
 #d # #
 
	4 	D 	d S T *s  # # 	=j 	= (H(=xHH .$e!^6G  Ks   B* *B43B4