Ë
    øÿæi¿”  ã                   ó–  — d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ej"                  rd dlZddlmZ ddlmZ ddlmZmZmZ  ed«      Zeeeed	f   gef   Zeeef   Z ej                  Z!d
Z"dZ#dZ$de	e   defd„Z%de de	e   fd„Z&d„ Z'ee
e	e      e
e	e      e	e   eeef   e
e	e      ef   Z(eeeef   d	f   Z)e	eeef      Z* G d„ d«      Z+de+de	e   de*de(fd„Z,  e jZ                  d«      e,«      Z.de+dede de)def
d„Z/de+dede de)def
d„Z0 e jZ                  d «      d!ed"e d#eed	f   d$ede+f
d%„«       Z1d!ed"e d#eed	f   deee+f   fd&„Z2ede	e   d!ed'e de!def
d(„«       Z3eded!ed'e de!def
d)„«       Z3deee	e   f   d!ed'e de!def
d*„Z3ede	e   d!ede!defd+„«       Z4eded!ede!defd,„«       Z4deee	e   f   d!ede!defd-„Z4ede	e   d!ede!defd.„«       Z5eded!ede!defd/„«       Z5deee	e   f   d!ede!defd0„Z5d1ed!ede6fd2„Z7d3„ Z8eZ9dede9fd4„Z:d5„ Z; e jZ                  d «      d!edefd6„«       Z<ej                   ded!edefd7„«       Z=ej                   d8ed9ed!edefd:„«       Z=ej                   d8ed9ed;ed!edef
d<„«       Z=ej                   d8ed9ed;ed=ed!edefd>„«       Z=d?eeef   defd@„Z=y)Aé    N)ÚOrderedDict)ÚAnyÚCallableÚDictÚListÚOptionalÚSetÚTupleÚTypeVarÚUnionÚcastÚoverloadé   )ÚEinopsError)Úget_backend)ÚAnonymousAxisÚParsedExpressionÚ	_ellipsisÚTensor.)ÚminÚmaxÚsumÚmeanÚprodÚanyÚalliÁ½ðÿiayþÿÚsequenceÚreturnc                 ó"   — d}| D ]  }||z  }Œ	 |S )zSminimalistic product that works both with numbers and symbols. Supports empty listsr   © )r   ÚresultÚelements      úb/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/einops/einops.pyÚ_productr$      s    € à€FÛˆØ�'Ñ‰ð à€Mó    Úreduction_typeÚreduced_axesc                 óÊ   — t        |«      r || t        |«      «      S |t        v sJ ‚|dk(  r|j                  | «      st	        d«      ‚|j                  | |t        |«      «      S )Nr   z5reduce_mean is not available for non-floating tensors)ÚcallableÚtupleÚ_reductionsÚis_float_typeÚNotImplementedErrorÚreduce)Útensorr&   r'   Úbackends       r#   Ú_reduce_axesr1   %   sf   € Ü�Ôá˜f¤e¨LÓ&9Ó:Ð:ð ¤Ñ,Ð,Ð,Ø˜VÒ#Ø×(Ñ(¨Ô0Ü)Ð*aÓbÐbØ�~‰~˜f n´e¸LÓ6IÓJÐJr%   c                 ób  ‡ ‡‡‡— t        ‰«      t        ‰«      z   t        ‰ «      k(  sJ ‚t        t        ‰«      «      Št        t        ‰«      dz
  «      d d d…   D ]`  }‰|   dz   ‰|dz      k(  sŒ‰|dz      Š‰ ‰   }‰ d ‰ ‰ ‰dz   d  z   Š ‰ ‰dz
  xx   |z  cc<   ‰d |dz    t        d„ ‰|dz   d  D «       «      z   ŠŒb ˆˆ ˆfd„} |«       }t        t        ‰ «      dz
  «      d d d…   D ]¿  }||   €Œ	||dz      €Œ||   dz   ||dz      k(  sŒ$|dz   Š‰ ‰   }t	        ˆfd„t        ‰«      D «       «      }	t        ˆfd„‰D «       «      Š‰ d ‰ ‰ ‰dz   d  z   Š ‰ ‰dz
  xx   |z  cc<   ‰}
g Š|
D ]3  }||	k(  rŒ	||	k  r‰j                  |«       Œ ‰j                  |dz
  «       Œ5  |«       }ŒÁ ‰ ‰‰|fS )Nr   éÿÿÿÿc              3   ó&   K  — | ]	  }|d z
  –— Œ y­w©r   Nr    )Ú.0Úaxiss     r#   Ú	<genexpr>z+_optimize_transformation.<locals>.<genexpr>?   s   è ø€ Ð8dÑNcÀd¸À½ÑNcùs   ‚é   c                  óÌ   •— i } t        t        ‰«      «      D ]I  }|‰v rd | |<   Œt        d„ | j                  «       D «       «      }t	        ‰«      j                  |«      | |<   ŒK | S )Nc              3   ó$   K  — | ]  }|d u–— Œ
 y ­w©Nr    )r6   Úxs     r#   r8   zB_optimize_transformation.<locals>.build_mapping.<locals>.<genexpr>H   s   è ø€ Ð%TÑ=S¸ a¨t¤mÑ=Sùs   ‚)ÚrangeÚlenr   ÚvaluesÚlistÚindex)Úinit_to_finalr7   Úafter_reductionÚaxes_reorderingÚinit_shapesr'   s      €€€r#   Úbuild_mappingz/_optimize_transformation.<locals>.build_mappingB   si   ø€ ØˆÜœ#˜kÓ*Ö+ˆDØ�|Ñ#Ø&*�˜dÒ#ä"%Ñ%T¸]×=QÑ=QÔ=SÓ%TÓ"T�Ü&*¨?Ó&;×&AÑ&AÀ/Ó&R�˜dÒ#ð ,ð Ðr%   c              3   ó&   •K  — | ]  }|‰v–— Œ
 y ­wr<   r    )r6   r=   r'   s     €r#   r8   z+_optimize_transformation.<locals>.<genexpr>V   s   øè ø€ Ð.bÑNaÈ¨q¸Ô/DÑNaùs   ƒc              3   ó6   •K  — | ]  }|‰k  r|n|d z
  –— Œ y­wr5   r    )r6   r7   Úremoved_axiss     €r#   r8   z+_optimize_transformation.<locals>.<genexpr>X   s$   øè ø€ Ð dÑWcÈt¨°Ò)<¡À$ÈÁ(Ó!JÑWcùs   ƒ)r?   r*   Úsortedr>   r   Úappend)rF   r'   rE   Úfinal_shapesÚiÚremoved_lengthrG   Úinit_axis_to_final_axisÚ	init_axisÚremoved_axis_after_reductionÚold_reorderingr7   rJ   s   ```         @r#   Ú_optimize_transformationrT   2   s0  û€ ô ˆÓ¤# lÓ"3Ñ3´s¸;Ó7GÒGÐGÐGô œ Ó-Ó.€LÜ”3�|Ó$ qÑ(Ó)©$¨B¨$Ô/ˆØ˜‰?˜QÑ ,¨q°1©uÑ"5Ó5Ø'¨¨A©Ñ.ˆLØ(¨Ñ6ˆNØ% m |Ð4°{À<ÐRSÑCSÐCUÐ7VÑVˆKØ˜ qÑ(Ó)¨^Ñ;Ó)Ø'¨¨!¨a©%Ð0´5Ñ8dÈlÐ[\Ð_`Ñ[`Ð[bÑNcÓ8dÓ3dÑd‰Lð 0öñ ,›oÐäœ3˜{Ó+¨aÑ/Ó0±°2°Ô6ˆ	Ø" 9Ñ-Ð5ØØ" 9¨q¡=Ñ1Ð9ØØ" 9Ñ-°Ñ1Ð5LÈYÐYZÉ]Ñ5[Ó[Ø$ q™=ˆLØ(¨Ñ6ˆNÜ+.Ó.bÌeÐT`ÔNaÓ.bÓ+bÐ(ä Ó dÑWcÓ dÓdˆLØ% m |Ð4°{À<ÐRSÑCSÐCUÐ7VÑVˆKØ˜ qÑ(Ó)¨^Ñ;Ó)Ø,ˆNØ ˆOÛ&�ØÐ7Ò7ØØÐ8Ò8Ø#×*Ñ*¨4Õ0à#×*Ñ*¨4°!©8Õ4ð 'ñ '4£oÑ#ð- 7ð0 ˜ o°|ÐCÐCr%   c                   ó|   — e Zd ZdZdee   deeef   deeee   ee   f      dee   dedeeef   deee      fd	„Z	y
)ÚTransformRecipezi
    Recipe describes actual computation pathway.
    Recipe can be applied to a tensor or variable.
    Úelementary_axes_lengthsÚaxis_name2elementary_axisÚinput_composition_known_unknownÚaxes_permutationÚfirst_reduced_axisÚ
added_axesÚoutput_composite_axesc                 óf   — || _         || _        || _        || _        || _        || _        || _        y r<   ©rW   rX   rY   rZ   r[   r\   r]   )ÚselfrW   rX   rY   rZ   r[   r\   r]   s           r#   Ú__init__zTransformRecipe.__init__{   s<   € ð, 3JˆÔ$Ø9RˆÔ&ØRqˆÔ,Ø+;ˆÔà'9ˆÔØ*4ˆŒØ6KˆÕ"r%   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úintr   Ústrr
   ra   r    r%   r#   rV   rV   r   s‘   „ ñðLð
 "& c¡ðLð $(¨¨S¨¡>ðLð *.¨e°D¸±I¸tÀC¹yÐ4HÑ.IÑ)JðLð ˜s™)ðLð  ðLð" ˜˜c˜‘Nð#Lð(  $ D¨¡I™ô)Lr%   rV   r`   ÚshapeÚ	axes_dimsc                 ó  — d}t        | j                  «      }|D ]  \  }}||| j                  |   <   Œ t        | j                  «      D ]ì  \  }\  }}	||   }
t        |«      dk(  rt        |	«      dk(  r	|
||	d   <   Œ3d}|D ]
  }|||   z  }Œ t        |	«      dk(  r6t        |
t        «      rnt        |t        «      r^|
|k7  rYt        d|
› d|› �«      ‚t        |
t        «      r)t        |t        «      r|
|z  dk7  rt        d|
› d|› �«      ‚|	d   }|
|z  }|||<   t        |«      t        |	«      z   dk7  sŒëd}Œî |r|d	t        | j                  «       nd	}d}g }| j                  D ]?  }|D �cg c]  }||   ‘Œ	 }}|j                  t        |«      «       t        |«      dk7  sŒ>d}ŒA | j                  j                  «       D ��ci c]  \  }}|||   “Œ }}}t        t        | j                   t        | j                  «      «      «      }t        |«      t        | j                  «      z   }| j                  }| j                  t        t        t        | j                  «      «      «      k(  rd	}|r|nd	}||||||fS c c}w c c}}w )
zä
    Reconstruct all actual parameters using shape.
    Shape is a tuple that may contain integers, shape symbols (tf, theano) and UnknownSize (tf, previously mxnet)
    known axes can be integers or symbols, but not Nones.
    Fr   r   zShape mismatch, z != z,Shape mismatch, can't divide axis of length z in chunks of TN)rA   rW   rX   Ú	enumeraterY   r?   Ú
isinstancerf   r   rZ   r]   rL   r$   r\   Úitemsr>   r[   )r`   rh   ri   Úneed_init_reshapeÚaxes_lengthsr7   ÚdimÚ
input_axisÚ
known_axesÚunknown_axesÚlengthÚknown_productÚunknown_axisÚinferred_lengthrF   Úneed_final_reshaperM   ÚgroupingÚelementary_axisÚlengthsÚposÚpos_in_elementaryr\   r'   Ún_axes_after_adding_axesrE   Ú_final_shapess                              r#   Ú _reconstruct_from_shape_uncachedr€   ›   sÁ  € ð Ðô # 4×#?Ñ#?Ó@€LÛ‰	ˆˆcØ=@ˆ�T×3Ñ3°DÑ9Ò:ð ô 3<¸D×<`Ñ<`Ö2aÑ.ˆ
Ñ.�Z Ø�zÑ"ˆÜˆz‹?˜aÒ¤C¨Ó$5¸Ò$:à,2ˆL˜ a™Ñ)ØàˆÛˆDØ˜\¨$Ñ/Ñ/‰Mð ô ˆ|Ó Ò!Ü˜&¤#Ô&¬:°mÄSÔ+IÈfÐXeÒNeÜ!Ð$4°V°H¸DÀÀÐ"PÓQÐQô ˜&¤#Ô&¬:°mÄSÔ+IÈfÐWdÑNdÐhiÒNiÜ!Ð$PÐQWÐPXÐXfÐgtÐfuÐ"vÓwÐwà'¨™?ˆLØ#)¨]Ñ#:ˆOØ)8ˆL˜Ñ&äˆz‹?œS Ó.Ñ.°!Ó3Ø $Ñð1 3bñ: Vg |Ð4P´c¸$×:OÑ:OÓ6PÑ'QÐlp€KàÐØ €LØ×.Ô.ˆÙHPÓQÉ°_�< Ó0ÈˆÐQØ×ÑœH WÓ-Ô.Üˆw‹<˜1ÓØ!%Ñð	 /ð LPÏ?É?×K`ÑK`ÔKbô"ÙKbÑ1G°Ð6Gˆˆ\Ð+Ñ,Ñ,ÐKbð ñ "ô
 œ˜d×5Ñ5´s¸4×;PÑ;PÓ7QÓRÓS€Lä" :›´°T×5JÑ5JÓ1KÑKÐà+/×+@Ñ+@€OØ×Ñ¤¤U¬3¨t×/DÑ/DÓ+EÓ%FÓ GÒGØˆá$6‘L¸D€MØ˜¨°zÀ=ÐRjÐjÐjùò' Rùó
"s   Å+I9ÇI>i   Úreciper/   ro   c                 ó¬  — 	 t        || j                  |«      |«      \  }}}}}	}
|�| j	                  ||«      }|�| j                  ||«      }t        |«      dkD  rt        |||| ¬«      }t        |«      dkD  r| j                  ||
|¬«      }|	�| j	                  ||	«      }|S # t        $ r( t        || j                  |«      |«      }|\  }}}}}	}
Y Œ­w xY w)Nr   )r&   r'   r0   )Ún_axesÚpos2len)	Ú_reconstruct_from_shaperh   Ú	TypeErrorr€   ÚreshapeÚ	transposer?   r1   Úadd_axes)r0   r�   r/   r&   ro   rF   rE   r'   r\   rM   Ún_axes_w_addedÚ_results               r#   Ú_apply_reciperŒ   æ   sú   € ðiÜ_vØ�G—M‘M &Ó)¨<ó`
Ñ\ˆ�_ l°JÀÈnð ÐØ—‘ ¨Ó5ˆØÐ"Ø×"Ñ" 6¨?Ó;ˆÜ
ˆ<Ó˜1ÒÜ˜f°^ÐR^ÐhoÔpˆÜ
ˆ:ƒ˜ÒØ×!Ñ! &°ÈÐ!ÓTˆØÐØ—‘ ¨Ó6ˆØ€Møô ò iä2°6¸7¿=¹=ÈÓ;PÐR^Ó_ˆØahÑ^ˆ�o |°ZÀÊ~ðiús   ‚#B" Â".CÃCc                 óZ  — t        ||j                  |«      \  }}}}}	}
|�| j                  ||«      }|�| j                  ||«      }t	        |«      dkD  rEt        |«      r ||t        |«      «      }n'|t        v sJ ‚ t        | |«      |t        |«      ¬«      }t	        |«      dkD  ro|j                  «       D ]  \  }}| j                  ||¬«      }Œ t        |j                  «      }|j                  «       D ]
  \  }}|||<   Œ | j                  ||«      }|	�| j                  ||	«      }|S )Nr   )r7   )r…   rh   r‡   Úpermute_dimsr?   r)   r*   r+   Úgetattrrm   Úexpand_dimsrA   Úbroadcast_to)Úxpr�   r/   r&   ro   rF   rE   r'   r\   rM   rŠ   Úaxis_positionÚ_axis_lengthÚfinal_shapeÚaxis_lengths                  r#   Ú_apply_recipe_array_apir—   ÿ   s<  € ô \sØ�—‘˜ló\ÑX€K� ,°
¸LÈ.ð ÐØ—‘˜F KÓ0ˆØÐ"Ø—‘ ¨Ó9ˆÜ
ˆ<Ó˜1ÒÜ�NÔ#á# F¬E°,Ó,?Ó@‰Fð "¤[Ñ0Ð0Ð0Ø0”W˜R Ó0°¼eÀLÓ>QÔRˆFÜ
ˆ:ƒ˜Òà+5×+;Ñ+;Ö+=Ñ'ˆM˜<Ø—^‘^ F°�^Ó?‰Fð ,>ô ˜6Ÿ<™<Ó(ˆØ*4×*:Ñ*:Ö*<Ñ&ˆM˜;Ø)4ˆK˜Ò&ð +=ð —‘ ¨Ó5ˆØÐØ—‘˜F LÓ1ˆØ€Mr%   é   ÚpatternÚ	operationÚ
axes_namesÚndimc           
      óþ  — | j                  d«      \  }}t        |«      }t        |«      }|j                  s|j                  rt        d| › �«      ‚|j                  r|j                  rt        d| › �«      ‚|dk(  rj|j
                  s|j
                  rt        d«      ‚t        j                  |j                  |j                  «      }t        |«      dkD  �r4t        d|› �«      ‚|dk(  r¯t        j                  |j                  |j                  «      }t        |«      dkD  rt        d	|› �«      ‚t        j                  |j                  D �	ch c]  }	t        |	t        «      rŒ|	’Œ c}	h |j                  £|£«      }
t        |
«      dkD  r€t        d
|
› �«      ‚|t        v st        |«      rIt        j                  |j                  |j                  «      }t        |«      dkD  r't        d|› d|› �«      ‚t        d|› dt        › d�«      ‚|j                  �r t        |j                  «      dz
  }||k  rt        d|› d|› d�«      ‚||z
  }t!        |«      D �cg c]  }t"        t%        |«      z   ‘Œ }}g }|j                  D ]6  }|t"        k(  r|D ]  }|j'                  |g«       Œ Œ&|j'                  |«       Œ8 g }|j                  D ]k  }|t"        k(  r|D ]  }|j'                  |g«       Œ Œ&g }|D ].  }|t"        k(  r|j)                  |«       Œ|j'                  |«       Œ0 |j'                  |«       Œm |j                  j+                  |«       |j                  j-                  t"        «       |j                  r�|j                  j+                  |«       |j                  j-                  t"        «       nU|t        |j                  «      k7  r%t        dt        |j                  «      › d|› d�«      ‚|j                  }|j                  }t/        «       }|D ]2  }|D ]+  }t        |t        «      r|j0                  ||<   Œ#t2        ||<   Œ- Œ4 g }|j                  D ]A  }||vsŒt        |t        «      r|j0                  ||<   n	t2        ||<   |j'                  |«       ŒC t5        |«      D ��ci c]  \  }}||“Œ
 }}}|D ]?  }t        j6                  |«      st        d|«      ‚||vrt        d|› d�«      ‚t8        ||<   ŒA g }|D ]°  }|D �ch c]  }||   t2        k7  sŒ|’Œ }}|D �ch c]  }||   t2        k(  sŒ|’Œ }}t        |«      dkD  rt        d|› �«      ‚t        |«      t        |«      z   t        |«      k(  sJ ‚|j'                  |D �cg c]  }||   ‘Œ	 c}|D �cg c]  }||   ‘Œ	 c}f«       Œ² i }t;        j<                  |Ž D ]  }||j                  v sŒt        |«      ||<   Œ! t5        |«      D ���cg c]  \  }}|D �cg c]  }||   ‘Œ	 c}‘Œ }}}}t?        t;        j<                  |Ž «      } t?        t;        j<                  |Ž «      }!| D �cg c]  }||j                  vsŒ|‘Œ }"}|!D �cg c]  }||j                  v sŒ|‘Œ c}|"z   }#|#D �cg c]  }| jA                  |«      ‘Œ }$}t5        |!«      D ��ci c]  \  }}||j                  vr|||   “Œ }%}}t        |#«      t        |"«      z
  }&tC        t?        |jE                  «       «      |D �ci c]  }|||   “Œ
 c}||$|&|%|¬«      S c c}	w c c}w c c}}w c c}w c c}w c c}w c c}w c c}w c c}}}w c c}w c c}w c c}w c c}}w c c}w )z†Perform initial parsing of pattern and provided supplementary info
    axes_lengths is a tuple of tuples (axis_name, axis_length)
    ú->z=Ellipsis found in right side, but not left side of a pattern z=Ellipsis inside parenthesis in the left side is not allowed: Ú	rearrangezQNon-unitary anonymous axes are not supported in rearrange (exception is length 1)r   z@Identifiers only on one side of expression (should be on both): Úrepeatz3Unexpected identifiers on the left side of repeat: z&Specify sizes for new axes in repeat: z3Unexpected identifiers on the right side of reduce z: zUnknown reduction z. Expect one of Ú.r   zWrong shape: expected >=z dims. Received z-dim tensor.zWrong shape: expected zInvalid name for an axiszAxis z is not used in transformzCould not infer sizes for r_   )#Úsplitr   Úhas_ellipsisr   Úhas_ellipsis_parenthesizedÚhas_non_unitary_anonymous_axesÚsetÚsymmetric_differenceÚidentifiersr?   Ú
differencerl   r   r+   r)   Úcompositionr>   r   rg   rL   ÚextendÚupdateÚremover   ÚvalueÚ_unknown_axis_lengthrk   Úcheck_axis_nameÚ_expected_axis_lengthÚ	itertoolsÚchainrA   rB   rV   r@   )'r™   rš   r›   rœ   Úleft_strÚrght_strÚleftÚrghtr©   ÚaxÚaxes_without_sizeÚn_other_dimsÚellipsis_ndimrN   Úell_axesÚleft_compositionÚcomposite_axisr7   Úrght_compositionÚgroupÚaxis_name2known_lengthÚ	axis_nameÚrepeat_axes_namesÚpositionÚnameÚaxis_name2positionrz   Úinput_axes_known_unknownÚknownÚunknownÚaxis_position_after_reductionÚresult_axes_groupingÚordered_axis_leftÚordered_axis_rghtr'   Úorder_after_transpositionrZ   r\   r[   s'                                          r#   Ú_prepare_transformation_reciperÏ   !  sØ  € ð !Ÿ™ tÓ,Ñ€HˆhÜ˜HÓ%€DÜ˜HÓ%€Dð ×Ò ×!2Ò!2ÜÐYÐZaÐYbÐcÓdÐdØ×Ò˜T×<Ò<ÜÐYÐZaÐYbÐcÓdÐdØ�KÒØ×.Ò.°$×2UÒ2UÜÐqÓrÐrÜ×-Ñ-¨d×.>Ñ.>À×@PÑ@PÓQˆ
Üˆz‹?˜QÓÜÐ `ÐakÐ`lÐmÓnÐnØ	�hÒ	Ü—^‘^ D×$4Ñ$4°d×6FÑ6FÓGˆ
Üˆz‹?˜QÒÜÐ SÐT^ÐS_Ð`ÓaÐaÜŸN™NØ×*Ò*ÓPÑ*�B´*¸RÄÕ2OŠRÐ*ÑPØ,ˆd×ÑÐ, Ð,ó
Ðô Ð Ó! AÒ%ÜÐ FÐGXÐFYÐZÓ[Ð[Ø	”kÑ	!¤X¨iÔ%8Ü—^‘^ D×$4Ñ$4°d×6FÑ6FÓGˆ
Üˆz‹?˜QÒÜÐ SÐT]ÐS^Ð^`ÐakÐ`lÐmÓnÐnäÐ.¨y¨kÐ9IÌ+ÈÐVWÐXÓYÐYà×ÓÜ˜4×+Ñ+Ó,¨qÑ0ˆØ�,ÒÜÐ 8¸¸ÐFVÐW[ÐV\Ð\hÐiÓjÐjØ˜|Ñ+ˆÜ05°mÔ0DÓEÑ0D¨1”I¤ A£Ó&Ð0DˆÐEØÐØ"×.Ô.ˆNØ¤Ò*Û$�DØ$×+Ñ+¨T¨FÕ3ñ %ð !×'Ñ'¨Õ7ð /ð ÐØ"×.Ô.ˆNØ¤Ò*Û$�DØ$×+Ñ+¨T¨FÕ3ñ %ð �Û*�DØœyÒ(ØŸ™ XÕ.àŸ™ TÕ*ð	 +ð
 !×'Ñ'¨Õ.ð /ð 	×Ñ×Ñ Ô)Ø×Ñ×Ñ¤	Ô*Ø×ÒØ×Ñ×#Ñ# HÔ-Ø×Ñ×#Ñ#¤IÕ.à”3�t×'Ñ'Ó(Ò(ÜÐ 6´s¸4×;KÑ;KÓ7LÐ6MÐM]Ð^bÐ]cÐcoÐpÓqÐqØ×+Ñ+ÐØ×+Ñ+Ðô DOÃ=ÐÛ*ˆÛ'ˆIÜ˜)¤]Ô3Ø4=·O±OÐ& yÒ1ä4HÐ& yÒ1ñ	 (ð +ð ÐØ×%Ô%ˆ	ØÐ2Ò2Ü˜)¤]Ô3Ø4=·O±OÐ& yÒ1ä4HÐ& yÑ1Ø×$Ñ$ YÕ/ð &ô @IÐI_Ô?`ÔaÑ?`©^¨X°t˜$ ™.Ð?`ÐÑaó &ˆÜ×/Ñ/°Ô@ÜÐ8¸/ÓJÐJØÐ"8Ñ8Ü  oÐ%6Ð6OÐPÓQÐQÜ2GÐ˜Ò/ð &ð  "Ðã*ˆÙ,:Ós©N DÐ>TÐUYÑ>ZÔ^rÓ>rš4¨NˆÐsÙ.<Óu©n dÐ@VÐW[Ñ@\Ô`tÓ@tšT¨nˆÐuÜˆw‹<˜!ÒÜÐ :¸7¸)ÐDÓEÐEÜ�7‹|œc %›jÑ(¬C°Ó,?Ò?Ð?Ð?Ø ×'Ñ'Ù38Ó9±5¨4Ð  Ó&°5Ñ9ÑahÓ;iÑahÐY]Ð<NÈtÓ<TÐahÑ;iÐjõ	
ð +ð 57Ð!Ü—_‘_Ð&6Ó7ˆ	Ø˜×(Ñ(Ò(Ü7:Ð;XÓ7YÐ)¨)Ò4ð 8ô
 XaÐaqÔWrõ-ÙWrÑBSÀ!À^©nÓ=©n dÐ	˜DÓ	!¨nÓ=ÐWrð ò -ô œYŸ_™_Ð.>Ð?Ó@ÐÜœYŸ_™_Ð.>Ð?Ó@ÐÙ%6ÓWÑ%6˜T¸$Àd×FVÑFVÒ:V’DÐ%6€LÐWÙ2CÓ `Ñ2C¨$ÀtÈt×O_ÑO_ÒG_¢Ð2CÑ `ÐcoÑ oÐÙB[Ó\ÑB[¸$Ð)×/Ñ/°Õ5ÐB[ÐÐ\ô &Ð&7Ô8ôá8‰LˆAˆyØ˜D×,Ñ,Ñ,ð 	
Ð˜iÑ(Ñ(Ø8ð ñ ô Ð6Ó7¼#¸lÓ:KÑKÐäÜ $Ð%;×%BÑ%BÓ%DÓ EÙNXÓ"YÉjÀd 4Ð);¸DÑ)AÑ#AÈjÑ"YØ(@Ø)Ø-ØØ2ôð ùòg Qùò" Fùól bùò tùÚuùò
 :ùÒ;iùò 	>ùô-ùò XùÚ `ùÚ\ùóùò #Zs~   Å\5Å$\5É\:Ò/\?Ô]Ô ]Ô*]
Ô<]
Ö]
Ö$]×?]Ø]Ø]Ù]%Ù.]%Ù8]*Ú]*Ú]/Û]4Ü]:
Ý]c           
      ó6  — | j                  d«      \  }}t        |«      }t        |j                  «      g}|j                  r1t        d«      D �cg c]  }t        |j                  «      dz
  |z   ‘Œ }}|D �ci c]  }|t        | |||¬«      “Œ c}S c c}w c c}w )z 
    Internal function, used in layers.
    Layer makes all recipe creation when it is initialized, thus to keep recipes simple we pre-compute for all dims
    rž   é   r   )rœ   )r¢   r   r?   rª   r£   r>   rÏ   )	r™   rš   r›   r´   rµ   r¶   ÚdimsÚellipsis_dimsrœ   s	            r#   Ú_prepare_recipes_for_all_dimsrÔ   ½  sž   € ð !Ÿ™ tÓ,Ñ€HˆhÜ˜HÓ%€DÜ�× Ñ Ó!Ð"€DØ×ÒÜOTÐUVÌxÓXÉx¸m”�D×$Ñ$Ó%¨Ñ)¨MÓ9ÈxˆÐXÙhlÓmÑhlÐ`dˆDÔ0°¸)ÀZÐVZÔ[Ñ[ÐhlÑmÐmùò YùÚms   Á"BÁ7BÚ	reductionc                  ó   — y r<   r    ©r/   r™   rÕ   ro   s       r#   r.   r.   Ì  s   € Øfir%   c                  ó   — y r<   r    r×   s       r#   r.   r.   Ð  s   € Ø`cr%   c                 ó&  — 	 t        | t        «      r9t        | «      dk(  rt        d«      ‚t	        | d   «      }|j                  | «      } nt	        | «      }t        |j                  «       «      }|j                  | «      }t        ||t        |«      t        |«      ¬«      }t        ||t        t        | «      ||¬«      S # t        $ rH}d|› d|› d�}	t        | t        «      s
|	d› d	�z  }	n|	d
z  }	|	d|› d�z  }	t        |	d|› �z   «      d‚d}~ww xY w)aé  
    einops.reduce combines rearrangement and reduction using reader-friendly notation.

    Some examples:

    ```python
    >>> x = np.random.randn(100, 32, 64)

    # perform max-reduction on the first axis
    # Axis t does not appear on RHS - thus we reduced over t
    >>> y = reduce(x, 't b c -> b c', 'max')

    # same as previous, but using verbose names for axes
    >>> y = reduce(x, 'time batch channel -> batch channel', 'max')

    # let's pretend now that x is a batch of images
    # with 4 dims: batch=10, height=20, width=30, channel=40
    >>> x = np.random.randn(10, 20, 30, 40)

    # 2d max-pooling with kernel size = 2 * 2 for image processing
    >>> y1 = reduce(x, 'b c (h1 h2) (w1 w2) -> b c h1 w1', 'max', h2=2, w2=2)

    # same as previous, using anonymous axes,
    # note: only reduced axes can be anonymous
    >>> y1 = reduce(x, 'b c (h1 2) (w1 2) -> b c h1 w1', 'max')

    # adaptive 2d max-pooling to 3 * 4 grid,
    # each element is max of 10x10 tile in the original tensor.
    >>> reduce(x, 'b c (h1 h2) (w1 w2) -> b c h1 w1', 'max', h1=3, w1=4).shape
    (10, 20, 3, 4)

    # Global average pooling
    >>> reduce(x, 'b c h w -> b c', 'mean').shape
    (10, 20)

    # subtracting mean over batch for each channel;
    # similar to x - np.mean(x, axis=(0, 2, 3), keepdims=True)
    >>> y = x - reduce(x, 'b c h w -> 1 c 1 1', 'mean')

    # Subtracting per-image mean for each channel
    >>> y = x - reduce(x, 'b c h w -> b c 1 1', 'mean')

    # same as previous, but using empty compositions
    >>> y = x - reduce(x, 'b c h w -> b c () ()', 'mean')

    ```

    Parameters:
        tensor: tensor: tensor of any supported library (e.g. numpy.ndarray, tensorflow, pytorch).
            list of tensors is also accepted, those should be of the same type and shape
        pattern: string, reduction pattern
        reduction: one of available reductions ('min', 'max', 'sum', 'mean', 'prod', 'any', 'all').
            Alternatively, a callable f(tensor, reduced_axes) -> tensor can be provided.
            This allows using various reductions like: np.max, np.nanmean, tf.reduce_logsumexp, torch.var, etc.
        axes_lengths: any additional specifications for dimensions

    Returns:
        tensor of the same type as input
    r   z9Rearrange/Reduce/Repeat can't be applied to an empty list)r›   rœ   )r&   ro   z Error while processing z-reduction pattern "z".z
 Input tensor shape: z. z
 Input is list. zAdditional info: r¡   z
 N)rl   rA   r?   r†   r   Ústack_on_zeroth_dimensionr*   rm   rh   rÏ   rŒ   r   r   r   )
r/   r™   rÕ   ro   r0   Úhashable_axes_lengthsrh   r�   ÚeÚmessages
             r#   r.   r.   Ô  s.  € ðx9Ü�fœdÔ#Ü�6‹{˜aÒÜÐ [Ó\Ð\Ü! &¨¡)Ó,ˆGØ×6Ñ6°vÓ>‰Fä! &Ó)ˆGä % l×&8Ñ&8Ó&:Ó ;ÐØ—‘˜fÓ%ˆÜ/°¸ÌuÐUaÓObÔilÐmrÓisÔtˆÜØ�VœT¤&¨&Ó1À)ÐZoô
ð 	
øô ò 9Ø,¨Y¨KÐ7KÈGÈ9ÐTVÐWˆÜ˜&¤$Ô'ØÐ0°°°rÐ:Ñ:‰GàÐ+Ñ+ˆGØÐ& | n°AÐ6Ñ6ˆÜ˜' c¨!¨ IÑ-Ó.°DÐ8ûð9ús   ‚B<B? Â?	DÃADÄDc                  ó   — y r<   r    ©r/   r™   ro   s      r#   rŸ   rŸ   )  s   € ØSVr%   c                  ó   — y r<   r    rß   s      r#   rŸ   rŸ   -  s   € ØMPr%   c                 ó    — t        | |fddi|¤ŽS )aü  
    einops.rearrange is a reader-friendly smart element reordering for multidimensional tensors.
    This operation includes functionality of transpose (axes permutation), reshape (view), squeeze, unsqueeze,
    stack, concatenate and other operations.

    Examples:

    ```python
    # suppose we have a set of 32 images in "h w c" format (height-width-channel)
    >>> images = [np.random.randn(30, 40, 3) for _ in range(32)]

    # stack along first (batch) axis, output is a single array
    >>> rearrange(images, 'b h w c -> b h w c').shape
    (32, 30, 40, 3)

    # stacked and reordered axes to "b c h w" format
    >>> rearrange(images, 'b h w c -> b c h w').shape
    (32, 3, 30, 40)

    # concatenate images along height (vertical axis), 960 = 32 * 30
    >>> rearrange(images, 'b h w c -> (b h) w c').shape
    (960, 40, 3)

    # concatenated images along horizontal axis, 1280 = 32 * 40
    >>> rearrange(images, 'b h w c -> h (b w) c').shape
    (30, 1280, 3)

    # flattened each image into a vector, 3600 = 30 * 40 * 3
    >>> rearrange(images, 'b h w c -> b (c h w)').shape
    (32, 3600)

    # split each image into 4 smaller (top-left, top-right, bottom-left, bottom-right), 128 = 32 * 2 * 2
    >>> rearrange(images, 'b (h1 h) (w1 w) c -> (b h1 w1) h w c', h1=2, w1=2).shape
    (128, 15, 20, 3)

    # space-to-depth operation
    >>> rearrange(images, 'b (h h1) (w w1) c -> b h w (c h1 w1)', h1=2, w1=2).shape
    (32, 15, 20, 12)

    ```

    When composing axes, C-order enumeration used (consecutive elements have different last axis).
    Find more examples in einops tutorial.

    Parameters:
        tensor: tensor of any supported library (e.g. numpy.ndarray, tensorflow, pytorch).
                list of tensors is also accepted, those should be of the same type and shape
        pattern: string, rearrangement pattern
        axes_lengths: any additional specifications for dimensions

    Returns:
        tensor of the same type as input. If possible, a view to the original tensor is returned.

    rÕ   rŸ   ©r.   rß   s      r#   rŸ   rŸ   1  s   € ôn �&˜'ÑI¨[ÐI¸LÑIÐIr%   c                  ó   — y r<   r    rß   s      r#   r    r    k  s   € ØPSr%   c                  ó   — y r<   r    rß   s      r#   r    r    o  s   € ØJMr%   c                 ó    — t        | |fddi|¤ŽS )a•  
    einops.repeat allows reordering elements and repeating them in arbitrary combinations.
    This operation includes functionality of repeat, tile, and broadcast functions.

    Examples for repeat operation:

    ```python
    # a grayscale image (of shape height x width)
    >>> image = np.random.randn(30, 40)

    # change it to RGB format by repeating in each channel
    >>> repeat(image, 'h w -> h w c', c=3).shape
    (30, 40, 3)

    # repeat image 2 times along height (vertical axis)
    >>> repeat(image, 'h w -> (repeat h) w', repeat=2).shape
    (60, 40)

    # repeat image 2 time along height and 3 times along width
    >>> repeat(image, 'h w -> (h2 h) (w3 w)', h2=2, w3=3).shape
    (60, 120)

    # convert each pixel to a small square 2x2, i.e. upsample an image by 2x
    >>> repeat(image, 'h w -> (h h2) (w w2)', h2=2, w2=2).shape
    (60, 80)

    # 'pixelate' an image first by downsampling by 2x, then upsampling
    >>> downsampled = reduce(image, '(h h2) (w w2) -> h w', 'mean', h2=2, w2=2)
    >>> repeat(downsampled, 'h w -> (h h2) (w w2)', h2=2, w2=2).shape
    (30, 40)

    ```

    When composing axes, C-order enumeration used (consecutive elements have different last axis).
    Find more examples in einops tutorial.

    Parameters:
        tensor: tensor of any supported library (e.g. numpy.ndarray, tensorflow, pytorch).
            list of tensors is also accepted, those should be of the same type and shape
        pattern: string, rearrangement pattern
        axes_lengths: any additional specifications for dimensions

    Returns:
        Tensor of the same type as input. If possible, a view to the original tensor is returned.

    rÕ   r    râ   rß   s      r#   r    r    s  s   € ô^ �&˜'ÑF¨XÐF¸ÑFÐFr%   r=   c                 óx  — t        |d¬«      }t        | «      j                  | «      }|j                  «       rt	        d|› d|› �«      ‚t        |«      t        |j                  «      k7  rR|j                  r5t        |«      t        |j                  «      dz
  k  r"t	        d|› d|› �«      ‚t	        d|› d|› �«      ‚|j                  rk|j                  j                  t        «      }|j                  d| d	gt        |«      t        |j                  «      z
  dz   z  z   |j                  |dz   d z   }n|j                  }i }t        ||«      D ]j  \  }}t        |«      d
k(  r|dk7  sŒt	        d|› d|› �«      ‚|\  }	t        |	t        «      r|	d	k7  sŒE|||	<   ŒK|	j                  |k7  sŒ[t	        d|› d|› �«      ‚ |S )aé  
    Parse a tensor shape to dictionary mapping axes names to their lengths.

    ```python
    # Use underscore to skip the dimension in parsing.
    >>> x = np.zeros([2, 3, 5, 7])
    >>> parse_shape(x, 'batch _ h w')
    {'batch': 2, 'h': 5, 'w': 7}

    # `parse_shape` output can be used to specify axes_lengths for other operations:
    >>> y = np.zeros([700])
    >>> rearrange(y, '(b c h w) -> b c h w', **parse_shape(x, 'b _ h w')).shape
    (2, 10, 5, 7)

    ```

    For symbolic frameworks may return symbols, not integers.

    Parameters:
        x: tensor of any supported framework
        pattern: str, space separated names for axes, underscore means skip axis

    Returns:
        dict, maps axes names to their lengths
    T©Úallow_underscorez'Can't parse shape with composite axes: Ú r   z2Can't parse shape with this number of dimensions: z7Can't parse shape with different number of dimensions: NÚ_r   zLength of axis is not 1: z)Length of anonymous axis does not match: )r   r   rh   Úhas_composed_axesÚRuntimeErrorr?   rª   r£   rB   r   Úziprl   rg   r®   )
r=   r™   Úexprh   Úellipsis_idxrª   r!   Úaxesr–   r7   s
             r#   Úparse_shaperñ   ¥  sÐ  € ô4 ˜7°TÔ
:€CÜ˜‹N× Ñ  Ó#€EØ
×ÑÔÜÐDÀWÀIÈQÈuÈgÐVÓWÐWÜ
ˆ5ƒz”S˜Ÿ™Ó)Ò)Ø×ÒÜ�5‹zœC §¡Ó0°1Ñ4Ò4Ü"Ð%WÐX_ÐW`Ð`aÐbgÐahÐ#iÓjÐjäÐ!XÐY`ÐXaÐabÐchÐbiÐjÓkÐkØ
×ÒØ—‘×,Ñ,¬YÓ7ˆà�O‰O˜M˜\Ð*Øˆe”s˜5“z¤C¨¯©Ó$8Ñ8¸1Ñ<Ñ=ñ>à�o‰o˜l¨QÑ.Ð0Ð1ñ2ñ 	ð —o‘oˆØ€FÜ  ¨eÖ4Ñˆˆkäˆt‹9˜Š>Ø˜aÓÜ"Ð%>¸w¸iÀqÈÈÐ#PÓQÐQà‰FˆTÜ˜$¤Ô$Ø˜3“;Ø#.�F˜4’Là—:‘: Ó,Ü&Ð)RÐSZÐR[Ð[\Ð]bÐ\cÐ'dÓeÐeð 5ð €Mr%   c           	      óò   — t        | «      }|j                  | «      }g }t        |«      D ]J  \  }}dgt        |«      z  }|||<   |j	                  |j                  |j                  d|«      |«      «       ŒL |S )aa  
    For an n-dimensional tensor, returns tensors to enumerate each axis.
    ```python
    x = np.zeros([2, 3, 4]) # or any other tensor
    i, j, k = _enumerate_directions(x)
    result = i + 2*j + 3*k
    ```

    `result[i, j, k] = i + 2j + 3k`, and also has the same shape as result
    Works very similarly to numpy.ogrid (open indexing grid)
    r   r   )r   rh   rk   r?   rL   r‡   Úarange)r=   r0   rh   r!   Úaxis_idr–   s         r#   Ú_enumerate_directionsrõ   ä  sv   € ô ˜!‹n€GØ�M‰M˜!Ó€EØ€FÜ )¨%Ö 0Ñˆ�Ø�”c˜%“jÑ ˆØ$ˆˆg‰Ø�‰�g—o‘o g§n¡n°Q¸Ó&DÀeÓLÕMð !1ð €Mr%   c                 ó6   — t        | «      j                  | «      S )zí
    Convert a tensor of an imperative framework (i.e. numpy/cupy/torch/jax/etc.) to `numpy.ndarray`

    Parameters:
        tensor: tensor of any known imperative framework

    Returns:
        `numpy.ndarray`, converted to numpy
    )r   Úto_numpy)r/   s    r#   Úasnumpyrø   þ  s   € ô �vÓ×'Ñ'¨Ó/Ð/r%   c                 ó  — t        | «      dk(  rt        d«      ‚t        | «      dkD  rt        d«      ‚| d   } t        | t        «      rt        d«      ‚t        | «      dk(  rt	        d«      ‚t        | t
        «      st	        d«      ‚y )Nr   z2Singleton () axes are not yet supported in einsum.r   z3Shape rearrangement is not yet supported in einsum.z/Anonymous axes are not yet supported in einsum.z&Encountered empty axis name in einsum.z%Axis name in einsum must be a string.)r?   r-   rl   r   rì   rg   )rÂ   s    r#   Ú_validate_einsum_axis_namerú     s„   € Ü
ˆ9ƒ~˜ÒÜ!Ð"VÓWÐWÜ
ˆ9ƒ~˜ÒÜ!Ð"WÓXÐXà˜!‘€Iä�)œ]Ô+Ü!Ð"SÓTÐTÜ
ˆ9ƒ~˜ÒÜÐCÓDÐDÜ�i¤Ô%ÜÐBÓCÐCð &r%   c                 ó¬  — d| vrt        d«      ‚| j                  d«      \  }}|j                  d«      D �cg c]  }t        |dd¬«      ‘Œ }}t        |d¬«      }t        j                  }d}i }g }	|D ]w  }d}
|j
                  D ]S  }|t        k(  r|
d	z  }
Œt        |«       |d   }||vr&|t        |«      k\  rt        d
«      ‚||   ||<   |dz  }|
||   z  }
ŒU |	j                  |
«       Œy dj                  |	«      dz   }|j
                  D ]?  }|t        k(  r|d	z  }Œt        |«       |d   }||vrt        d|› d| › d�«      ‚|||   z  }ŒA |S c c}w )Nrž   z!Einsum pattern must contain '->'.Ú,T)rè   Úallow_duplicatesrç   r   Ú z...zToo many axes in einsum.r   zUnknown axis z on right side of einsum r¡   )Ú
ValueErrorr¢   r   ÚstringÚascii_lettersrª   r   rú   r?   rì   rL   Újoinr   )r™   Ú	lefts_strÚ	right_strr¶   ÚleftsÚrightÚoutput_axis_namesrN   Úaxis_name_mappingÚleft_patternsÚleft_patternÚraw_axis_namerÂ   Úcompact_patterns                 r#   Ú_compactify_pattern_for_einsumr    s¶  € à�7Ñô Ð<Ó=Ð=Ø"Ÿ=™=¨Ó.Ñ€Iˆyà^g×^mÑ^mÐnqÔ^rÓsÑ^rÐVZÔ˜d°TÈDÖQÐ^r€EÐsä˜Y¸Ô>€Eô ×,Ñ,ÐØ	€AØÐà€MÛˆØˆØ!×-Ô-ˆMØ¤	Ò)Ø Ñ%�Øä& }Ô5Ø% aÑ(ˆIØÐ 1Ñ1ØœÐ-Ó.Ò.Ü&Ð'AÓBÐBØ/@ÀÑ/CÐ! )Ñ,Ø�Q‘�àÐ-¨iÑ8Ñ8‰Lð .ð 	×Ñ˜\Õ*ð! ð$ —h‘h˜}Ó-°Ñ4€Oà×*Ô*ˆØœIÒ%Ø˜uÑ$ˆOØä" =Ô1Ø! !Ñ$ˆ	àÐ-Ñ-Ü ¨i¨[Ð8QÐRYÐQZÐZ[Ð\Ó]Ð]àÐ,¨YÑ7Ñ7‰ð +ð ÐùòW ts   ·Ec                 ó   — y r<   r    )r/   r™   s     r#   Úeinsumr  Q  s   € Ø7:r%   Útensor1Útensor2c                 ó   — y r<   r    )r  r  r™   s      r#   r  r  U  s   € ØILr%   Útensor3c                 ó   — y r<   r    )r  r  r  r™   s       r#   r  r  Y  s   € ØZ]r%   Útensor4c                 ó   — y r<   r    )r  r  r  r  r™   s        r#   r  r  ]  s   € Øknr%   Útensors_and_patternc                  óÒ   — t        | «      dk  rt        d«      ‚| d   }t        |t        «      st        d«      ‚| dd }t	        |«      } t        |d   «      j                  |g|¢­Ž S )aü  
    einops.einsum calls einsum operations with einops-style named
    axes indexing, computing tensor products with an arbitrary
    number of tensors. Unlike typical einsum syntax, here you must
    pass tensors first, and then the pattern.

    Also, note that rearrange operations such as `"(batch chan) out"`,
    or singleton axes `()`, are not currently supported.

    Examples:

    For a given pattern such as:
    ```python
    >>> x, y, z = np.random.randn(3, 20, 20, 20)
    >>> output = einsum(x, y, z, "a b c, c b d, a g k -> a b k")

    ```
    the following formula is computed:
    ```tex
    output[a, b, k] = \sum_{c, d, g} x[a, b, c] * y[c, b, d] * z[a, g, k]
    ```
    where the summation over `c`, `d`, and `g` is performed
    because those axes names do not appear on the right-hand side.

    Let's see some additional examples:
    ```python
    # Filter a set of images:
    >>> batched_images = np.random.randn(128, 16, 16)
    >>> filters = np.random.randn(16, 16, 30)
    >>> result = einsum(batched_images, filters,
    ...                 "batch h w, h w channel -> batch channel")
    >>> result.shape
    (128, 30)

    # Matrix multiplication, with an unknown input shape:
    >>> batch_shape = (50, 30)
    >>> data = np.random.randn(*batch_shape, 20)
    >>> weights = np.random.randn(10, 20)
    >>> result = einsum(weights, data,
    ...                 "out_dim in_dim, ... in_dim -> ... out_dim")
    >>> result.shape
    (50, 30, 10)

    # Matrix trace on a single tensor:
    >>> matrix = np.random.randn(10, 10)
    >>> result = einsum(matrix, "i i ->")
    >>> result.shape
    ()

    ```

    Parameters:
        tensors_and_pattern:
            tensors: tensors of any supported library (numpy, tensorflow, pytorch, jax).
            pattern: string, einsum pattern, with commas
                separating specifications for each tensor.
                pattern should be provided after all tensors.

    Returns:
        Tensor of the same type as input, after processing with einsum.

    r   zd`einops.einsum` takes at minimum two arguments: the tensors (at least one), followed by the pattern.r3   z^The last argument passed to `einops.einsum` must be a string, representing the einsum pattern.Nr   )r?   rÿ   rl   rg   r  r   r  )r  r™   Útensorss      r#   r  r  a  s‚   € ô~ ÐÓ 1Ò$ÜØró
ð 	
ð " "Ñ%€GÜ�gœsÔ#ÜØló
ð 	
ð " # 2Ð&€GÜ,¨WÓ5€GØ)Œ;�w˜q‘zÓ"×)Ñ)¨'Ð<°GÒ<Ð<r%   )>Ú	functoolsr²   r   ÚtypingÚcollectionsr   r   r   r   r   r   r	   r
   r   r   r   r   ÚTYPE_CHECKINGÚnumpyÚnprþ   r   Ú	_backendsr   Úparsingr   r   r   r   rf   ÚReductionCallablerg   Ú	ReductionÚSizer+   r¯   r±   r$   r1   rT   ÚCookedRecipeÚHashableAxesLengthsÚFakeHashableAxesLengthsrV   r€   Ú	lru_cacher…   rŒ   r—   rÏ   rÔ   r.   rŸ   r    Údictrñ   rõ   Ú
np_ndarrayrø   rú   r  r  r    r%   r#   Ú<module>r+     sd  ðÛ Û Û Û Ý #ß b× b× bÑ bà	×Òãå Ý "ß ?Ñ ?á	�Ó	€Ø˜f e¨C°¨H¡oÐ6¸Ð>Ñ?Ð Ø�#Ð(Ð(Ñ)€	Ø‡z�z€àA€ð Ð ØÐ ð�t˜C‘yð  Só ð
K¨ð 
KÀ$ÀsÁ)ó 
Kò4Dðn �X˜d 3™iÑ(¨(°4¸±9Ñ*=¸tÀC¹yÈ$ÈsÐTWÈxÉ.ÐZbÐcgÐhkÑclÑZmÐorÐrÑs€ð
 ˜E # s (™O¨SÐ0Ñ1Ð Ø˜u S¨# X™Ñ/Ð ÷&Lñ &LðREkØ
ðEkØ"& s¡)ðEkØ8OðEkàóEkðP 4Ð-˜)×-Ñ-¨dÓ3Ð4TÓUÐ ðØ$ðØ.4ðØFOðØ_rðàóð2ØðØ)/ðØAJðØZmðàóðD €×Ñ�SÓðXØðXàðXð �c˜3�h‘ðXð ð	Xð
 òXó ðXðvnØðnØ&ðnØ49¸#¸s¸(±Oðnà	ˆ#ˆÐ
Ñónð 
Ø i�4˜‘<Ð i¨#Ð i¸)Ð iÐUYÐ iÐ^dÒ ió 
Ø ið 
Ø c�6Ð c CÐ c°IÐ cÈtÐ cÐX^Ò có 
Ø cðR9�5˜  f¡Ð-Ñ.ð R9¸ð R9Èð R9Ðdhð R9Ðmsó R9ðj 
Ø V�d˜6‘lÐ V¨SÐ VÀ$Ð VÈ6Ò Vó 
Ø Vð 
Ø P�fÐ P sÐ P¸DÐ PÀVÒ Pó 
Ø Pð7J�e˜F D¨¡LÐ0Ñ1ð 7J¸Cð 7JÐQUð 7JÐZ`ó 7Jðt 
Ø S�4˜‘<Ð S¨#Ð S¸tÐ SÈÒ Só 
Ø Sð 
Ø M�6Ð M CÐ M¸Ð MÀ&Ò Mó 
Ø Mð/G�5˜  f¡Ð-Ñ.ð /G¸ð /GÈdð /GÐW]ó /Gðd;�6ð ; Cð ;¨Dó ;ò~ð. €
ð
0�Fð 
0˜zó 
0òDð  €×Ñ�SÓð2¨Cð 2°Cò 2ó ð2ðj ‡�Ø :�6Ð : CÐ :¨vÒ :ó Ø :ð ‡�Ø L�FÐ L VÐ L°cÐ LÀÒ Ló Ø Lð ‡�Ø ]�FÐ ] VÐ ]°fÐ ]ÀsÐ ]ÐRXÒ ]ó Ø ]ð ‡�Ø n�FÐ n VÐ n°fÐ nÀvÐ nÐX[Ð nÐciÒ nó Ø nðJ=  v¨s {Ñ!3ð J=¸ô J=r%   