
    3Ki/                        S SK Jr  S SKJr  S SKrS SKJrJr  S SKJr  S SK	J
r
  \r/ SQr " S S5      r " S	 S
\R                  5      r " S S\R                  5      r " S S\5      r\r " S S5      rg)    )annotationsN)MappingMutableMappingref)Tensor)TensorWeakRef	WeakIdRefWeakIdKeyDictionaryWeakTensorKeyDictionaryc                  *    \ rS rSrSS jrS rS rSrg)_IterationGuard   c                $    [        U5      U l        g N)r   weakcontainer)selfr   s     R/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/torch/utils/weak.py__init___IterationGuard.__init__   s     /    c                b    U R                  5       nUb  UR                  R                  U 5        U $ r   )r   
_iteratingadd)r   ws     r   	__enter___IterationGuard.__enter__#   s,     =LLT"r   c                    U R                  5       nUb6  UR                  nUR                  U 5        U(       d  UR                  5         g g g r   )r   r   remove_commit_removals)r   etbr   ss         r   __exit___IterationGuard.__exit__)   sB     =AHHTN""$  r   )r   NreturnNone)__name__
__module____qualname____firstlineno__r   r   r%   __static_attributes__ r   r   r   r      s    0%r   r   c                  N   ^  \ rS rSrS/rSS	U 4S jjjrU 4S jrS rS rSr	U =r
$ )
r
   K   _idc                D   > [        U5      U l        [        TU ]  X5        g r   )idr2   superr   r   keycallback	__class__s      r   r   WeakIdRef.__init__N   s     c7'r   c                f   > [         TU ]  5       n[        US5      (       a  UR                  5         U$ N_fix_weakrefr5   __call__hasattrr=   r   rr9   s     r   r?   WeakIdRef.__call__W   ,    G1n%%NNr   c                    U R                   $ r   r2   r   s    r   __hash__WeakIdRef.__hash__^       xxr   c                6    U " 5       nU" 5       nUb  Ub  X#L $ XL $ r   r/   r   otherar#   s       r   __eq__WeakIdRef.__eq__a   s*     FG=Q]6M}r   rF   r   r'   r*   r+   r,   r-   	__slots__r   r?   rH   rO   r.   __classcell__r9   s   @r   r
   r
   K   s(    I( ( r   r
   c                  N   ^  \ rS rSrS/rSS	U 4S jjjrU 4S jrS rS rSr	U =r
$ )
_WeakHashRefw   r2   c                D   > [        U5      U l        [        TU ]  X5        g r   )hashr2   r5   r   r6   s      r   r   _WeakHashRef.__init__z   s     9'r   c                f   > [         TU ]  5       n[        US5      (       a  UR                  5         U$ r<   r>   rA   s     r   r?   _WeakHashRef.__call__   rD   r   c                    U R                   $ r   rF   rG   s    r   rH   _WeakHashRef.__hash__   rJ   r   c                ^    U " 5       nU" 5       nUb  Ub  [        U5      [        U5      :H  $ XL $ r   )rY   rL   s       r   rO   _WeakHashRef.__eq__   s6     FG=Q]7d1g%%}r   rF   r   r'   rQ   rT   s   @r   rV   rV   w   s(    I( ( r   rV   c                      \ rS rSrS\4SS jjrSS jrSS jrSS jrS r	SS jr
SS	 jrSS
 jrS r\rS rSS jrS S jrS rS r\rS rS rS rS rSS jrSSS jjrS rS rS rS rSrg)!r      Nc                    0 U l         X l        [        U 5      4SS jjnX0l        / U l        [        5       U l        SU l        Ub  U R                  U5        g g )Nc                    U" 5       nUb<  UR                   (       a  UR                  R                  U 5        g  UR                  U 	 g g ! [         a     g f = fr   )r   _pending_removalsappenddataKeyError)kselfrefr   s      r   r   ,WeakIdKeyDictionary.__init__.<locals>.remove   sS    9D??**11!4 IIaL   $ s   A 
AAFr'   )	rg   ref_typer   _removere   setr   
_dirty_lenupdate)r   dictrl   r   s       r   r   WeakIdKeyDictionary.__init__   sP    	 !$i 		 !#%KK r   c                    U R                   R                  nU R                  n  U" 5       n X#	 M  ! [         a     g f = f! [         a     Nf = fr   )re   poprg   
IndexErrorrh   )r   rt   dr7   s       r   r    $WeakIdKeyDictionary._commit_removals   sc    
 $$((IIeF   
  s   1 A 
>>
AAc                    U R                   nU R                   Vs/ s H  o"U;   d  M
  UPM     snU l        SU l        g s  snf NF)rg   re   ro   )r   rv   ri   s      r   _scrub_removals#WeakIdKeyDictionary._scrub_removals   s;    II-1-C-C!N-CAv!-C!N "Os   	>>c                J    SU l         U R                  U R                  U5      	 g NT)ro   rg   rl   r   r7   s     r   __delitem__WeakIdKeyDictionary.__delitem__   s    IIdmmC()r   c                >    U R                   U R                  U5         $ r   )rg   rl   r~   s     r   __getitem__WeakIdKeyDictionary.__getitem__   s    yys+,,r   c                    U R                   (       a!  U R                  (       a  U R                  5         [        U R                  5      [        U R                  5      -
  $ r   )ro   re   rz   lenrg   rG   s    r   __len__WeakIdKeyDictionary.__len__   s=    ??t55   "499~D$:$: ;;;r   c                P    SU R                   R                   S[        U 5      S S3$ )N<z at z#x>)r9   r*   r4   rG   s    r   __repr__WeakIdKeyDictionary.__repr__   s(    4>>**+44}A>>r   c                R    X R                   U R                  XR                  5      '   g r   )rg   rl   rm   )r   r7   values      r   __setitem__WeakIdKeyDictionary.__setitem__   s    6;		$--\\23r   c                    [        5       n[        U 5         U R                  R                  5        H  u  p#U" 5       nUc  M  X1U'   M     S S S 5        U$ ! , (       d  f       U$ = fr   )r   r   rg   items)r   newr7   r   os        r   copyWeakIdKeyDictionary.copy   sX    !#T""iioo/
E="F 0 #
 
 #"
 
s   (AA
A#c                    SSK Jn  U R                  5       n[        U 5         U R                  R                  5        H  u  pEU" 5       nUc  M  U" XQ5      X6'   M     S S S 5        U$ ! , (       d  f       U$ = f)Nr   )deepcopy)r   r   r9   r   rg   r   )r   memor   r   r7   r   r   s          r   __deepcopy__ WeakIdKeyDictionary.__deepcopy__   sd    !nnT""iioo/
E=%e2CF 0 #
 
 #"
 
s   (A&A&&
A5c                X    U R                   R                  U R                  U5      U5      $ r   )rg   getrl   r   r7   defaults      r   r   WeakIdKeyDictionary.get   s     yy}}T]]3/99r   c                b     U R                  U5      nX R                  ;   $ ! [         a     gf = fry   )rl   	TypeErrorrg   )r   r7   wrs      r   __contains__ WeakIdKeyDictionary.__contains__   s7    	s#B YY  		s   ! 
..c              #     #    [        U 5         U R                  R                  5        H  u  pU" 5       nUc  M  X24v   M     S S S 5        g ! , (       d  f       g = f7fr   r   rg   r   )r   r   r   r7   s       r   r   WeakIdKeyDictionary.items   sC     T"!YY__.	d?*$ / #""s!   A(A	A	A
AAc              #     #    [        U 5         U R                   H  nU" 5       nUc  M  Uv   M     S S S 5        g ! , (       d  f       g = f7fr   )r   rg   )r   r   objs      r   keysWeakIdKeyDictionary.keys  s7     T"iid?I   #""s   A;;	A
A	Ac              #     #    [        U 5         U R                  R                  5        H  u  pU" 5       c  M  Uv   M     S S S 5        g ! , (       d  f       g = f7fr   r   )r   r   r   s      r   valuesWeakIdKeyDictionary.values  s<     T"!YY__.	4#K / #""s!   A&A	A	 	A	
AAc                ,    [        U R                  5      $ )aJ  Return a list of weak references to the keys.

The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the keys around longer than needed.

)listrg   rG   s    r   keyrefsWeakIdKeyDictionary.keyrefs  s     DIIr   c                h    SU l          U R                  R                  5       u  pU" 5       nUb  X24$ M+  r}   )ro   rg   popitem)r   r7   r   r   s       r   r   WeakIdKeyDictionary.popitem  s8    **,JCA}x	 r   c                h    SU l         U R                  R                  " U R                  U5      /UQ76 $ r}   )ro   rg   rt   rl   )r   r7   argss      r   rt   WeakIdKeyDictionary.pop(  s*    yy}}T]]3/7$77r   c                l    U R                   R                  U R                  XR                  5      U5      $ r   )rg   
setdefaultrl   rm   r   s      r   r   WeakIdKeyDictionary.setdefault-  s+    yy##MM#||,g
 	
r   c                   U R                   nUbX  [        US5      (       d  [        0 5      " U5      nUR                  5        H"  u  pEXSU R	                  X@R
                  5      '   M$     U(       a  U R                  U5        g g )Nr   )rg   r@   typer   rl   rm   rp   )r   rq   kwargsrv   r7   r   s         r   rp   WeakIdKeyDictionary.update2  sf    II4))Bx~"jjl
6;$--\\23 +KK r   c                (    U R                  U5        U $ r   )rp   )r   rM   s     r   __ior__WeakIdKeyDictionary.__ior__<  s    Er   c                    [        U[        R                  5      (       a#  U R                  5       nUR	                  U5        U$ [
        $ r   )
isinstance_collections_abcr   r   rp   NotImplementedr   rM   cs      r   __or__WeakIdKeyDictionary.__or__@  s7    e-5566		AHHUOHr   c                    [        U[        R                  5      (       a4  U R                  5       nUR	                  U5        UR	                  U 5        U$ [
        $ r   )r   r   r   r9   rp   r   r   s      r   __ror__WeakIdKeyDictionary.__ror__G  sC    e-5566 AHHUOHHTNHr   c                   [        U[        5      (       d  [        $ U R                  5        VVs0 s H  u  p#[	        U5      U_M     snnUR                  5        VVs0 s H  u  p#[	        U5      U_M     snn:H  $ s  snnf s  snnf r   )r   r   r   r   r4   )r   rM   ri   vs       r   rO   WeakIdKeyDictionary.__eq__Q  sp    %))!!%)ZZ\2\TQ1q\2!&7
!.BqE1H7
 
 	
2 7
s   A;B)ro   r   re   rm   rg   rl   r'   )r(   int)r(   strr   )r(   bool) r*   r+   r,   r-   r
   r   r    rz   r   r   r   r   r   r   __copy__r   r   r   r   r   __iter__r   r   r   rt   r   rp   r   r   r   rO   r.   r/   r   r   r   r      s     9 0$ 
*-<?< H	:% H 
 8


 
r   r   c                  4    \ rS rSr% SrS\S'   S	S jrS rSrg)
r	   i]  zuWrapper around a weak ref of a Tensor that handles the _fix_weakref() call required when unwrapping a Tensor weakref.zWeakRef[Tensor]r   c                    [        U[        5      (       d  [        S[        U5       S35      e[        R
                  " U5      U l        g Nzexpected torch.Tensor, got .)r   r   AssertionErrorr   weakrefr   )r   tensors     r   r   TensorWeakRef.__init__b  s8    &&)) #>tF|nA!NOO;;v&r   c                    U R                  5       nUc  U$ [        U[        5      (       d  [        S[	        U5       S35      eUR                  5         U$ r   )r   r   r   r   r   r=   )r   outs     r   r?   TensorWeakRef.__call__g  sN    hhj;J#v&& #>tCyk!KLL
r   r   N)r   r   r(   r)   )	r*   r+   r,   r-   __doc____annotations__r   r?   r.   r/   r   r   r	   r	   ]  s    	'
r   r	   )
__future__r   collections.abcabcr   r   r   r   r   torchr   WeakRef__all__r   r
   rV   r   r   r	   r/   r   r   <module>r      ss    " *  3   % %d' 'X7;; D}
. }
B .  r   