
    iD                     &   S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSKJ	r
  SSKJr  SS	KJr  / S
QrSSSSSSS.rSS jr\R$                  \R&                  \R(                  \R$                  \R&                  \R*                  S.rSS jr0 rS r0 rS r\
R8                  \R8                  \R8                  \R8                  \R8                  S.r\
R<                  \R<                  \R<                  \R<                  \R<                  S.rS rS rS r g)z
Handles dispatching array operations to the correct backend library, as well
as converting arrays to backend formats and then potentially storing them as
constants.
    N   )object_arrays)cupy)jax)
tensorflow)theano)torch)get_func
has_einsumhas_tensordotbuild_expressionevaluate_constantshas_backendz
dask.arrayztheano.tensorzopt_einsum.backends.torchz	jax.numpyzautograd.numpyzmars.tensor)daskr   r	   r   autogradmarsc                      [         R                  " [        R                  X5      5      nUc  [	        X05      $ [	        X0U5      $ ! [
         a    Sn[        UR                  X5      5      ef = f)zTry and import ``{backend}.{func}``.
If library is installed and func is found, return the func;
otherwise if default is provided, return default;
otherwise raise an error.
z{} doesn't seem to provide the function {} - see https://optimized-einsum.readthedocs.io/en/latest/backends.html for details on which functions are required for which contractions.)	importlibimport_module_aliasesgetgetattrAttributeErrorformat)funcbackenddefaultlib	error_msgs        \/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/opt_einsum/backends/dispatch.py_import_funcr!      sj    >%%hll7&DE%,_ws!U'#W:UU >[	 Y--g<==	>s   6A A 'A,))	tensordotnumpy)	transposer#   )einsumr#   )r"   object)r$   r&   )r%   r&   c                 h     [         X4   $ ! [         a    [        XU5      nU[         X4'   Us $ f = f)zaReturn ``{backend}.{func}``, e.g. ``numpy.einsum``,
or a default func if provided. Cache result.
)_cached_funcsKeyErrorr!   )r   r   r   fns       r    r
   r
   <   s@    T]++ $1')dm$	s   	 "11c                      [         U    $ ! [         a<     [        SU 5        S[         U '   O! [         a    S[         U '    Of = f[         U    s $ f = f)zHCheck if ``{backend}.einsum`` exists, cache result for performance.
    r%   TF)_has_einsumr)   r
   r   r   s    r    r   r   L   s`    	$7## $	)Xw'#'K  	)#(K 	) 7##$.    
A,AAAAAAc                      [         U    $ ! [         a<     [        SU 5        S[         U '   O! [         a    S[         U '    Of = f[         U    s $ f = f)zKCheck if ``{backend}.tensordot`` exists, cache result for performance.
    r"   TF)_has_tensordotr)   r
   r   r-   s    r    r   r   ^   s`    	'g&& '	,['*&*N7# 	,&+N7#	, g&&'r.   )r   r   r   r	   r   c                      [         U    " X5      $ )zpBuild an expression, based on ``expr`` and initial arrays ``arrays``,
that evaluates using backend ``backend``.
)CONVERT_BACKENDSr   arraysexprs      r    r   r      s     G$V22    c                      [         U    " X5      $ )z{Convert constant arrays to the correct backend, and perform as much of
the contraction of ``expr`` with these as possible.
)EVAL_CONSTS_BACKENDSr3   s      r    r   r      s      (66r6   c                 0    U R                  5       [        ;   $ )z$Checks if the backend is known.
    )lowerr2   r-   s    r    r   r      s     ==?...r6   )N)r#   N)!__doc__r   r#    r   r   _cupyr   _jaxr   _tensorflowr   _theanor	   _torch__all__r   r!   r"   r$   r%   object_einsumr(   r
   r,   r   r0   r   r   r2   r   r8   r    r6   r    <module>rE      s        '  
n ( >& "OO!OO"__"__'55	 $ '$ ..&&""$$    00(($$&&"" 37/r6   