
    JThX+                        S SK Jr  S SKrS SKJr  S SKJr  S SKJrJr  S SK	J
r
  S SKJr  \r/ SQr " S S	\R                  5      r " S
 S\R                  5      r " S S\5      r\r " S S5      rg)    )annotationsNref)_IterationGuard)MutableMappingMapping)Tensor)TensorWeakRef	WeakIdRefWeakIdKeyDictionaryWeakTensorKeyDictionaryc                  J   ^  \ rS rSrS/rSU 4S jjrU 4S jrS rS rSr	U =r
$ )	r   +   _idc                D   > [        U5      U l        [        TU ]  X5        g N)idr   super__init__selfkeycallback	__class__s      H/var/www/auris/envauris/lib/python3.13/site-packages/torch/utils/weak.pyr   WeakIdRef.__init__.   s     c7'    c                f   > [         TU ]  5       n[        US5      (       a  UR                  5         U$ N_fix_weakrefr   __call__hasattrr    r   rr   s     r   r"   WeakIdRef.__call__7   ,    G1n%%NNr   c                    U R                   $ r   r   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   otherabs       r   __eq__WeakIdRef.__eq__A   s*     FG=Q]6M}r   r)   r   __name__
__module____qualname____firstlineno__	__slots__r   r"   r+   r4   __static_attributes____classcell__r   s   @r   r   r   +   s#    I( r   r   c                  J   ^  \ rS rSrS/rSU 4S jjrU 4S jrS rS rSr	U =r
$ )	_WeakHashRefV   r   c                D   > [        U5      U l        [        TU ]  X5        g r   )hashr   r   r   r   s      r   r   _WeakHashRef.__init__Y   s     9'r   c                f   > [         TU ]  5       n[        US5      (       a  UR                  5         U$ r   r!   r$   s     r   r"   _WeakHashRef.__call__b   r'   r   c                    U R                   $ r   r)   r*   s    r   r+   _WeakHashRef.__hash__i   r-   r   c                ^    U " 5       nU" 5       nUb  Ub  [        U5      [        U5      :H  $ XL $ r   )rC   r0   s       r   r4   _WeakHashRef.__eq__l   s6     FG=Q]7d1g%%}r   r)   r   r6   r>   s   @r   r@   r@   V   s#    I( r   r@   c                      \ rS rSrS\4S jrS rS rS rS r	S r
S	 rS
 rS r\rS rSS jrS rS rS r\rS rS rS rS rSS jrSS jrS rS rS rS rSrg)r   w   Nc                    0 U l         X l        [        U 5      4S 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   )
_iterating_pending_removalsappenddataKeyError)kselfrefr   s      r   remove,WeakIdKeyDictionary.__init__.<locals>.remove}   sS    9D??**11!4 IIaL   $ s   A 
AAF)	rR   ref_typer   _removerP   setrO   
_dirty_lenupdate)r   dictrX   rV   s       r   r   WeakIdKeyDictionary.__init__x   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   )rP   poprR   
IndexErrorrS   )r   r`   dr   s       r   _commit_removals$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)rR   rP   r[   )r   rb   rT   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)r[   rR   rX   r   r   s     r   __delitem__WeakIdKeyDictionary.__delitem__   s    IIdmmC()r   c                >    U R                   U R                  U5         $ r   )rR   rX   rk   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   )r[   rP   rg   lenrR   r*   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>)r   r7   r   r*   s    r   __repr__WeakIdKeyDictionary.__repr__   s(    4>>**+44}A>>r   c                R    X R                   U R                  XR                  5      '   g r   )rR   rX   rY   )r   r   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   rR   items)r   newr   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   r   r   rR   r   )r   memor   r   r   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   )rR   getrX   r   r   defaults      r   r   WeakIdKeyDictionary.get   s     yy}}T]]3/99r   c                b     U R                  U5      nX R                  ;   $ ! [         a     gf = frf   )rX   	TypeErrorrR   )r   r   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   rR   r   )r   r   r{   r   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   rR   )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.

)listrR   r*   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+  rj   )r[   rR   popitem)r   r   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 $ rj   )r[   rR   r`   rX   )r   r   argss      r   r`   WeakIdKeyDictionary.pop  s*    yy}}T]]3/7$77r   c                l    U R                   R                  U R                  XR                  5      U5      $ r   )rR   
setdefaultrX   rY   r   s      r   r   WeakIdKeyDictionary.setdefault  s&    yy##DMM#||$DgNNr   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5      (       a  U R                  U5        g g )Nr   )rR   r#   typer   rX   rY   rr   r\   )r   r]   kwargsrb   r   r{   s         r   r\   WeakIdKeyDictionary.update
  sl    II4))Bx~"jjl
6;$--\\23 +v;;KK r   c                (    U R                  U5        U $ r   )r\   )r   r1   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   r\   NotImplementedr   r1   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   r   r\   r   r   s      r   __ror__WeakIdKeyDictionary.__ror__  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   r   )r   r1   rT   vs       r   r4   WeakIdKeyDictionary.__eq__)  sd    %))!!%)ZZ\2\TQ1q\2EKKM6ZMDAr!uaxM6ZZZ26Zs   A;B)r[   rO   rP   rY   rR   rX   r   ) r7   r8   r9   r:   r   r   rc   rg   rl   ro   rs   rx   r|   r   __copy__r   r   r   r   r   __iter__r   r   r   r`   r   r\   r   r   r   r4   r<   r/   r   r   r   r   w   s     9 .$ 
*-<?< H:% H 
 8O [r   r   c                  4    \ rS rSr% SrS\S'   S	S jrS rSrg)
r
   i2  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                h    [        U[        5      (       d   e[        R                  " U5      U l        g r   )r   r	   weakrefr   )r   tensors     r   r   TensorWeakRef.__init__7  s%    &&))));;v&r   c                ~    U R                  5       nUc  U$ [        U[        5      (       d   eUR                  5         U$ r   )r   r   r	   r    )r   outs     r   r"   TensorWeakRef.__call__;  s;    hhj;J#v&&&&
r   r   N)r   r	   )	r7   r8   r9   r:   __doc____annotations__r   r"   r<   r/   r   r   r
   r
   2  s    	'r   r
   )
__future__r   r   r   _weakrefsetr   collections.abcr   r   torchr	   abcr   WeakRef__all__r   r@   r   r   r
   r/   r   r   <module>r      sn    "   ' 3  *  [8' 'V7;; Bu[. u[p .  r   