
    [Thw                     "   % S SK r S SKJr  S SKJr  S SKJr  S SKrS SKJ	r	  S SK
JrJrJrJr  / r\\   \S'   \ " S S5      5       r\	R(                  " \/5         " S	 S
5      r\ \4S\S\S\S\SS4
S jjr  SSS.S\S\S\S\S\S\4S jjjrg)    N)	dataclass)BufferedIOBase)Any)_load_saveDEFAULT_PROTOCOLMAP_LOCATION__all__c                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)_Entry   key
is_storagelength N)	__name__
__module____qualname____firstlineno__str__annotations__boolint__static_attributes__r       X/var/www/auris/envauris/lib/python3.13/site-packages/torch/distributed/_serialization.pyr   r      s    	HKr   r   c                       \ rS rSrSS jrS\S\S\SS4S jrS	\	SS4S
 jr
S	\	SS4S jrS\S\4S jrS\S\4S jrS\S\S\S\R                   4S jrS\4S jrSrg)_PseudoZipFile   returnNc                     0 U l         g Nrecordsselfs    r   __init___PseudoZipFile.__init__   s	    68r   r   datar   c                 $    X#4U R                   U'   g r"   r#   )r&   r   r)   r   s       r   write_record_PseudoZipFile.write_record   s    !NSr   fc           
         / nU R                   R                  5        H:  u  nu  pEUR                  [        U[	        U[
        R                  5      US95        M<     [        R                  " X![        S9  U R                   R                  5        H  u  nu  pE[	        U[        5      (       a  UR                  U5        M0  [	        U[        5      (       a"  UR                  UR                  S5      5        Mg  [	        U[
        R                  5      (       a  UR                  USSS5        M  [        S[!        U5       35      e   g )N)r   r   r   )protocolutf-8F   zunknown type: )r$   itemsappendr   
isinstancetorchUntypedStoragepickledumpr   byteswriter   encode_write_file	TypeErrortype)r&   r-   entriesr   r)   r   s         r   write_to_PseudoZipFile.write_to   s    #'<<#5#5#7C$NN)$0D0DE! $8 	G)9:#'<<#5#5#7C$$&&D#&&G,-D%"6"677  E5!4.d =>> $8r   c                    [         R                  " U5      nU H  nUR                  UR                  5      nUR                  (       aX  [
        R                  " U[
        R                  S9R                  5       nUUR                  4U R                  UR                  '   M  XCR                  4U R                  UR                  '   M     g )Ndtype)_weights_only_unpicklerloadreadr   r   r5   
frombufferuint8untyped_storager$   r   )r&   r-   r?   entryr)   storages         r   	read_from_PseudoZipFile.read_from6   s    )..q1E66%,,'D**++ "/#  LL+UYY'
 ,0*>UYY' r   c                     XR                   ;   $ r"   r#   r&   r   s     r   
has_record_PseudoZipFile.has_recordH   s    ll""r   c                 &    U R                   U   S   $ )Nr   r#   rP   s     r   
get_record_PseudoZipFile.get_recordK   s    ||C ##r   _length_typec                 h    [         R                  " U R                  U   S   [         R                  S9$ )Nr   rC   )r5   tensorr$   rI   )r&   r   rV   rW   s       r   get_storage_from_record&_PseudoZipFile.get_storage_from_recordN   s'     ||DLL-a0DDr   c                     g)Ntorchftr   r%   s    r   serialization_id_PseudoZipFile.serialization_idS   s    r   r#   )r    N)r   r   r   r   r'   r   objectr   r+   r   r@   rM   r   rQ   rT   r5   TensorrZ   r^   r   r   r   r   r   r      s    9+ +6 +3 +4 +?. ?T ?.?> ?d ?$#c #d #$c $f $EE!$E-0E	E
# r   r   objr-   pickle_modulepickle_protocolr    c                 T    [        5       n[        U UUUSS9  UR                  U5        g)a  
Save the object to a file-like object in a streaming fashion compatible with
network sockets.

This behaves similarly to :func:`torch.save` with a few notable differences:

* A non-seekable file like object can be used when loading.
* No forwards/backwards compatiblity is provided for the serialization
  format. This is only intended to be used with a single version of PyTorch
  with transient storage (i.e. sockets or temp files).
* mmap is not supported

See :func:`torch.save` for more details on specific arguments.
F)zip_filerc   rd   _disable_byteorder_recordN)r   r   r@   )rb   r-   rc   rd   rf   s        r   _streaming_saverh   W   s3    * H	#'"' ar   T)weights_onlymap_locationri   pickle_load_argsc                    U(       a  Ub  [        S5      e[        nO	Uc  [        nSUR                  5       ;  a  SUS'   [	        5       nUR                  U 5        [        SUUUS.UD6$ )z
Load the object from a file-like object in a streaming fashion compatible with
network sockets.

See :func:`_streaming_save` for more details about the streaming behavior.

See :func:`torch.load` for more details on specific arguments.
zDCan not safely load weights when explicit pickle_module is specifiedencodingr0   )rf   rj   rc   r   )RuntimeErrorrE   r7   keysr   rM   r   )r-   rj   rc   ri   rk   rf   s         r   _streaming_loadrp   w   s      $V  0 "M)..00'.$Hq !# 	 r   )NN)r7   dataclassesr   ior   typingr   r5   torch._weights_only_unpicklerrE   torch.serializationr   r   r   r	   r
   listr   r   r   _add_safe_globalsr   r`   r   rh   r   rp   r   r   r   <module>rx      s     !    ? L L c      ) )6( 3< <D  +		  	
 
D "&$
 $$$ $
 $ $ $r   