+
    ic                     z    ^ RI t ^ RIHt ^ RIHt ^ RIHt ^ RIHt R t	R t
R tR	 tR
 tR tR tR tR R ltR# )    N)defaultdict)Permutation)Tuple)Integerc                 v    / p^ p\        V 4       F%  w  r4\        V4       F  pW53W&   V^,          pK  	  K'  	  V# )r   )	enumeraterange)subranksmappingcounterirankjs   &     b/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/tensor/array/expressions/utils.py_get_mapping_from_subranksr   	   sE    GGX&tA !vGqLG  ' N    c           	      .   \        V4      pV UUu. uF  qD Uu. uF  qSV,          NK  	  upNK  	  ppp\        \        4      pV F6  p\        V4      ^8X  g   K  Vw  w  rw  rW3Wy,          V
&   W3W{,          V&   K8  	  V \        V4      3# u upi u uppi )   )r   r   dictlen)argsr
   contraction_indicesr   r   r   contraction_tuplesdlinkslinksarg1pos1arg2pos2s   &&*          r   _get_contraction_linksr       s    (2G;NO;Naq1q!1::q1;NOF#u:?).&LT,4"&FL"&FL $ f 2Os   BBBBc                 x    V  Uu. uF  p\        \        V4      !  NK  	  p pV P                  R  R7       V # u upi )c                     \        V 4      # N)min)xs   &r   <lambda>+_sort_contraction_indices.<locals>.<lambda>#   s    s1vr   key)r   sortedsort)pairing_indicesr   s   & r   _sort_contraction_indicesr-   !   s=    2AB/QufQi(/OB-. Cs   7c                   a  \        \        4      p\        S 4       F:  w  r#\        V\        \
        34      '       d   K#  W,          P                  V4       K<  	  VP                  4        UUu/ uF  w  rE\        V4      ^8  g   K  WEbK  	  pppS  Uu. uF  q"V9  g   K  VNK  	  pp\        V4      pVP                  V 3R lR7       V Uu. uF  p\        W,          4      NK  	  ppWg,          p\        V4      pW3# u uppi u upi u upi )   c                 &   < SP                  V 4      # r#   )index)r%   flattened_indicess   &r   r&   '_get_diagonal_indices.<locals>.<lambda>2   s    $5$;$;A$>r   r(   )r   listr   
isinstanceintr   appenditemsr   r+   tuple)	r2   axes_contractionr   indkvret_indicesdiag_indicesdiagonal_indicess	   f        r   _get_diagonal_indicesrA   '   s    "4(-.cC>**$$Q'	 /
 *:)?)?)AP)ASVaZ)AP/M/<L3L11/KM()L>?<HILq.12LIK$K(( QM Js   -C?C?D DD
c                     \        V 4       F7  w  r#W8X  d   Vu # \        V\        \        34      '       g   K-  W9   g   K5  Vu # 	  \	        V: R V : 24      h)z not found in )r   r5   set	frozenset
IndexError)
subindicesr;   r   sinds   &&  r   _get_argindexrH   9   sJ    Z(;HdS),--#+H	 )
 S*=
>>r   c                 &  a  \        V\        \        \        34      '       d3   \        ;QJ d    . V 3R  lV 4       F  NK  	  5# ! V 3R  lV 4       4      # \        V\        4      '       d!   \        P                  ! V 3R lV 4       4      # S ! V4      # )c              3   <   <"   T F  p\        SV4      x  K  	  R # 5ir#   $_apply_recursively_over_nested_lists.0r   funcs   & r   	<genexpr>7_apply_recursively_over_nested_lists.<locals>.<genexpr>D   s     PCq9$BBC   c              3   <   <"   T F  p\        SV4      x  K  	  R # 5ir#   rK   rM   s   & r   rP   rQ   F   s     YUXPQB4KKUXrR   )r5   r9   r4   r   fromiter)rO   arrs   f&r   rL   rL   B   sf    #tU+,,uPCPuPuPCPPP	C		~~YUXYYYCyr   c                 T  a aaa ^ ^ /o^ p^ pV\        S 4      8  de   ^pW,           \        S 4      8  d/   S V,          V,           S W,           ,          8w  d   MV^,          pKD  W#,          pVSS V,          &   W,          pKt  \        SP                  4       4      oVV3R loV V3R lpV# )r   c                 \   < SS\         P                  ! SV 4      ^,
          ,          ,          # )r/   )bisectbisect_right)idx
shift_keysshiftss   &r   rO   8_build_push_indices_up_func_transformation.<locals>.funcZ   s%    j!4!4Z!Ea!GHIIr   c                 4   < V S9   d   R # V S! V 4      ,
          # r#    )r   flattened_contraction_indicesrO   s   &r   	transform=_build_push_indices_up_func_transformation.<locals>.transform]   s    --tAw;r   )r   r*   keys)r`   r   
cumulativer   ra   rO   r[   r\   s   f    @@@r   *_build_push_indices_up_func_transformationre   K   s    VF	AJ
c/0
0cC566,Q/!37TUVUX7YYFA
3=,Q/0	&JJ r   c                    a V R,          ^,           p\        V4       Uu. uF  q"V 9  g   K  VNK  	  upoV3R lpV# u upi )r/   c                    < V \        S4      8  d
   SV ,          # V SR,          ,           \        S4      ,
          ^,           # )r/   )r   )r   r\   s   &r   ra   ?_build_push_indices_down_func_transformation.<locals>.transformk   s4    s6{?!9vbz>CK/!33r   rh   )r	   )r`   Nr   ra   r\   s   &   @r   ,_build_push_indices_down_func_transformationrk   f   sE    %b)!+AqLA.K%KaaLF4  Ms   ==c                0    V ^8  d   QhR\         R\        /# )r   permtarget_list)r   r4   )formats   "r   __annotate__rp   t   s      [ t r   c                    \        V P                  4       Uu. uF  pRNK  	  pp\        V4       F  w  r$WCV ! V4      &   K  	  V# u upi )z4
Permute a list according to the given permutation.
N)r	   sizer   )rm   rn   r   new_listes   &&   r   _apply_permutation_to_listru   t   sJ     $DII./..H/+&a 'O 0s   A)rX   collectionsr   sympy.combinatoricsr   sympy.core.containersr   sympy.core.numbersr   r   r    r-   rA   rH   rL   re   rk   ru   r_   r   r   <module>rz      sA     # + ' &)$?6r   