
    ~Wh                        d Z ddlZddlZ G d d          Z G d de          Z G d de          Z G d	 d
ej        j                  Z G d de          Z	 G d dej        j
                  Z G d de          ZdS )z:Utilities for collecting objects based on "is" comparison.    Nc                   `    e Zd ZdZddgZd Zed             Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )_ObjectIdentityWrappera  Wraps an object, mapping __eq__ on wrapper to "is" on wrapped.

    Since __eq__ is based on object identity, it's safe to also define __hash__
    based on object ids. This lets us add unhashable types like trackable
    _ListWrapper objects to object-identity collections.
    _wrapped__weakref__c                     || _         d S Nr   )selfwrappeds     a/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/keras/utils/object_identity.py__init__z_ObjectIdentityWrapper.__init__    s        c                     | j         S r   r	   r
   s    r   	unwrappedz _ObjectIdentityWrapper.unwrapped#   s
    }r   c                 T    t          |t                    st          d|           d S )NzlCannot compare wrapped object with unwrapped object. Expect the object to be `_ObjectIdentityWrapper`. Got: )
isinstancer   	TypeErrorr
   others     r   _assert_typez#_ObjectIdentityWrapper._assert_type'   sC    %!788 	      	 	r   c                     |                      |           t          | j                  t          |j                  k     S r   r   idr   r   s     r   __lt__z_ObjectIdentityWrapper.__lt__/   5    %   $-  2en#5#555r   c                     |                      |           t          | j                  t          |j                  k    S r   r   r   s     r   __gt__z_ObjectIdentityWrapper.__gt__3   r   r   c                 P    |dS |                      |           | j        |j        u S )NF)r   r   r   s     r   __eq__z_ObjectIdentityWrapper.__eq__7   s/    =5%   }..r   c                 .    |                      |           S r   )r    r   s     r   __ne__z_ObjectIdentityWrapper.__ne__=   s    ;;u%%%%r   c                 *    t          | j                  S r   )r   r   r   s    r   __hash__z_ObjectIdentityWrapper.__hash__@   s     $-   r   c                 B    dt          |           j         d| j        dS )N<z
 wrapping >)type__name__r   r   s    r   __repr__z_ObjectIdentityWrapper.__repr__F   s&    D4::&DD$-DDDDr   N)r)   
__module____qualname____doc__	__slots__r   propertyr   r   r   r   r    r"   r$   r*    r   r   r   r      s          ]+I        X  6 6 66 6 6/ / /& & &! ! !E E E E Er   r   c                   8     e Zd ZdZ fdZed             Z xZS )_WeakObjectIdentityWrapperr0   c                 n    t                                          t          j        |                     d S r   )superr   weakrefref)r
   r   	__class__s     r   r   z#_WeakObjectIdentityWrapper.__init__N   s+    W--.....r   c                 *    |                                  S r   r	   r   s    r   r   z$_WeakObjectIdentityWrapper.unwrappedQ   s    }}r   )r)   r+   r,   r.   r   r/   r   __classcell__)r7   s   @r   r2   r2   J   sX        I/ / / / /   X    r   r2   c                   0    e Zd ZdZdZ e            Zd ZdS )	ReferencezReference that refers an object.

    ```python
    x = [1]
    y = [1]

    x_ref1 = Reference(x)
    x_ref2 = Reference(x)
    y_ref2 = Reference(y)

    print(x_ref1 == x_ref2)
    ==> True

    print(x_ref1 == y)
    ==> False
    ```
    r0   c                     | j         S )zReturns the referenced object.

        ```python
        x_ref = Reference(x)
        print(x is x_ref.deref())
        ==> True
        ```
        r	   r   s    r   derefzReference.derefn   s     }r   N)r)   r+   r,   r-   r.   r/   r   r=   r0   r   r   r;   r;   V   sA         $ I 

I	 	 	 	 	r   r;   c                   H    e Zd ZdZdgZd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )ObjectIdentityDictionarya&  A mutable mapping data structure which compares using "is".

    This is necessary because we have trackable objects (_ListWrapper) which
    have behavior identical to built-in Python lists (including being unhashable
    and comparing based on the equality of their contents by default).
    _storagec                     i | _         d S r   )r@   r   s    r   r   z!ObjectIdentityDictionary.__init__   s    r   c                      t          |          S r   r   r
   keys     r   	_wrap_keyz"ObjectIdentityDictionary._wrap_key       %c***r   c                 B    | j         |                     |                   S r   r@   rF   rD   s     r   __getitem__z$ObjectIdentityDictionary.__getitem__   s    }T^^C0011r   c                 @    || j         |                     |          <   d S r   rI   )r
   rE   values      r   __setitem__z$ObjectIdentityDictionary.__setitem__   s     -2dnnS))***r   c                 <    | j         |                     |          = d S r   rI   rD   s     r   __delitem__z$ObjectIdentityDictionary.__delitem__   s    M$..--...r   c                 *    t          | j                  S r   lenr@   r   s    r   __len__z ObjectIdentityDictionary.__len__       4=!!!r   c              #   0   K   | j         D ]}|j        V  d S r   )r@   r   rD   s     r   __iter__z!ObjectIdentityDictionary.__iter__   s2      = 	  	 C-	  	 r   c                 2    dt          | j                   dS )NzObjectIdentityDictionary())reprr@   r   s    r   r*   z!ObjectIdentityDictionary.__repr__   s    A4+>+>AAAAr   N)r)   r+   r,   r-   r.   r   rF   rJ   rM   rO   rS   rV   r*   r0   r   r   r?   r?   z   s          I  + + +2 2 23 3 3/ / /" " "     B B B B Br   r?   c                   *    e Zd ZdZdgZd Zd Zd ZdS )ObjectIdentityWeakKeyDictionaryz?Like weakref.WeakKeyDictionary, but compares objects with "is".r   c                      t          |          S r   r2   rD   s     r   rF   z)ObjectIdentityWeakKeyDictionary._wrap_key       )#...r   c                 D    t          t          | j                            S r   )rR   listr@   r   s    r   rS   z'ObjectIdentityWeakKeyDictionary.__len__   s    4&&'''r   c              #   h   K   | j                                         }|D ]}|j        }|| |= |V  d S r   )r@   keysr   r
   rb   rE   r   s       r   rV   z(ObjectIdentityWeakKeyDictionary.__iter__   sS      }!!## 	  	 CI II	  	 r   Nr)   r+   r,   r-   r.   rF   rS   rV   r0   r   r   r[   r[      sN        III/ / /( ( (         r   r[   c                   r    e Zd ZdZddgZd Zed             Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )ObjectIdentitySetz6Like the built-in set, but compares objects with "is".r@   r   c                 V     t           fdt          | D                        _        d S )Nc              3   B   K   | ]}                     |          V  d S r   rF   ).0objr
   s     r   	<genexpr>z-ObjectIdentitySet.__init__.<locals>.<genexpr>   s/      GGCDNN3//GGGGGGr   )setr`   r@   )r
   argss   ` r   r   zObjectIdentitySet.__init__   s/    GGGG4;GGGGGr   c                 0    t                      }| |_        |S r   )rf   r@   )storageresults     r   _from_storagezObjectIdentitySet._from_storage   s    "$$!r   c                      t          |          S r   rC   rD   s     r   rF   zObjectIdentitySet._wrap_key   rG   r   c                 :    |                      |          | j        v S r   )rF   r@   rD   s     r   __contains__zObjectIdentitySet.__contains__   s    ~~c""dm33r   c                 `    | j                             |                     |                     d S r   )r@   discardrF   rD   s     r   rw   zObjectIdentitySet.discard   s*    dnnS1122222r   c                 `    | j                             |                     |                     d S r   )r@   addrF   rD   s     r   ry   zObjectIdentitySet.add   s*    $..--.....r   c                 T      j                              fd|D                        d S )Nc                 :    g | ]}                     |          S r0   ri   rj   itemr
   s     r   
<listcomp>z,ObjectIdentitySet.update.<locals>.<listcomp>   s%    EEEtdnnT22EEEr   )r@   updater
   itemss   ` r   r   zObjectIdentitySet.update   s4    EEEEuEEEFFFFFr   c                 8    | j                                          d S r   )r@   clearr   s    r   r   zObjectIdentitySet.clear   s    r   c                 P      j                              fd|D                       S )Nc                 :    g | ]}                     |          S r0   ri   r|   s     r   r~   z2ObjectIdentitySet.intersection.<locals>.<listcomp>   s%    444dT^^D!!444r   )r@   intersectionr   s   ` r   r   zObjectIdentitySet.intersection   s4    }))4444e444
 
 	
r   c                      t                                j                             fd|D                                 S )Nc                 :    g | ]}                     |          S r0   ri   r|   s     r   r~   z0ObjectIdentitySet.difference.<locals>.<listcomp>   s%    %M%M%MtdnnT&:&:%M%M%Mr   )rf   rr   r@   
differencer   s   ` r   r   zObjectIdentitySet.difference   sC     ..M$$%M%M%M%Mu%M%M%MNN
 
 	
r   c                 *    t          | j                  S r   rQ   r   s    r   rS   zObjectIdentitySet.__len__   rT   r   c              #   N   K   t          | j                  }|D ]}|j        V  d S r   )r`   r@   r   )r
   rb   rE   s      r   rV   zObjectIdentitySet.__iter__   s?      DM"" 	  	 C-	  	 r   N)r)   r+   r,   r-   r.   r   staticmethodrr   rF   ru   rw   ry   r   r   r   r   rS   rV   r0   r   r   rf   rf      s        @@]+IH H H   \
+ + +4 4 43 3 3/ / /G G G  
 
 


 
 

" " "         r   rf   c                   (    e Zd ZdZdZd Zd Zd ZdS )ObjectIdentityWeakSetz5Like weakref.WeakSet, but compares objects with "is".r0   c                      t          |          S r   r]   rD   s     r   rF   zObjectIdentityWeakSet._wrap_key   r^   r   c                 4    t          d | D                       S )Nc                     g | ]}|S r0   r0   )rj   _s     r   r~   z1ObjectIdentityWeakSet.__len__.<locals>.<listcomp>   s    $$$!A$$$r   )rR   r   s    r   rS   zObjectIdentityWeakSet.__len__   s    $$t$$$%%%r   c              #      K   t          | j                  }|D ]%}|j        }||                     |           !|V  &d S r   )r`   r@   r   rw   rc   s       r   rV   zObjectIdentityWeakSet.__iter__   s[      DM"" 	  	 CI S!!!!	  	 r   Nrd   r0   r   r   r   r      sL        ??I/ / /& & &         r   r   )r-   collectionsr5   r   r2   r;   abcMutableMappingr?   r[   
MutableSetrf   r   r0   r   r   <module>r      sr   @ @      1E 1E 1E 1E 1E 1E 1E 1Eh	 	 	 	 	!7 	 	 	! ! ! ! !& ! ! !H!B !B !B !B !B{= !B !B !BH         &>      ,0  0  0  0  0 2 0  0  0 f         -          r   