Ë
    S²j8Z  ã                   ó&  — d dl Z d dlZd dlZd dl mZ d dlmZ d dlZd dlmZ 	 d dl	Z  G d„ d«      Z G d„ de«      Z e«       Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#d„ Z$y# e
$ r Y Œgw xY w) é    N)Ú	reduction)Úregister_after_fork)Úcheck_serializing_named_tensorc                   óF   — e Zd ZdZddgZd„ Zed„ «       Zd„ Zd„ Z	d„ Z
d	„ Zy
)ÚStorageWeakRefzŽA weak reference to a Storage.

    The cdata member is a Python number containing the integer representation of
    the Storage pointer.
    ÚcdataÚ_free_weak_refc                 ól   — |j                  «       | _        t        j                  j                  | _        y ©N)Ú	_weak_refr   ÚtorchÚStorager	   )ÚselfÚstorages     ú_/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/torch/multiprocessing/reductions.pyÚ__init__zStorageWeakRef.__init__    s&   € Ø×&Ñ&Ó(ˆŒ
ô $Ÿm™m×:Ñ:ˆÕó    c                 ót   — | j                  | «      }||_        t        j                  j                  |_        |S r   )Ú__new__r   r   r   r	   )Úclsr   Úinstances      r   Úfrom_weakrefzStorageWeakRef.from_weakref&   s.   € à—;‘;˜sÓ#ˆØˆŒÜ"'§-¡-×">Ñ">ˆÔØˆr   c                 óT   — t         j                  j                  | j                  «      S r   )r   r   Ú_expiredr   ©r   s    r   ÚexpiredzStorageWeakRef.expired-   s   € Ü�}‰}×%Ñ% d§j¡jÓ1Ð1r   c                 ó:   — | j                  | j                  «       y r   )r	   r   r   s    r   Ú__del__zStorageWeakRef.__del__0   s   € Ø×Ñ˜DŸJ™JÕ'r   c                 ó   — | j                   S r   )r   r   s    r   Ú__hash__zStorageWeakRef.__hash__3   s   € Ø�z‰zÐr   c                 ód   — t        | «      t        |«      k(  ry| j                  |j                  k(  S )NT)Úidr   )r   Úothers     r   Ú__eq__zStorageWeakRef.__eq__6   s(   € Üˆd‹8”r˜%“yÒ ØØ�z‰z˜UŸ[™[Ñ(Ð(r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   Úclassmethodr   r   r   r    r$   © r   r   r   r      sA   „ ñð Ð*Ð+€Iò;ð ñó ðò2ò(òó)r   r   c                   ó0   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zy)	ÚSharedCachez:Dictionary from multiprocessing handles to StorageWeakRef.Nc                 óf   — d| _         | j                  «        t        | t        j                  «       y )Né€   )ÚlimitÚ_after_forkr   r-   r   s    r   r   zSharedCache.__init__?   s)   € ð ˆŒ
ð 	×ÑÔÜ˜D¤+×"9Ñ"9Õ:r   c                 ó6   — t        j                  «       | _        y r   )Ú	threadingÚLockÚlockr   s    r   r1   zSharedCache._after_forkI   s   € Ü—N‘NÓ$ˆ�	r   c                 ór   — | j                   5  t        j                  | |«      cd d d «       S # 1 sw Y   y xY wr   )r5   ÚdictÚget)r   Úkeys     r   r8   zSharedCache.getL   s,   € Ø�Y‰Yñ 	'Ü—8‘8˜D #Ó&÷	'÷ 	'ò 	'ús   �-­6c                 óÄ   — | j                   5  t        j                  | ||«       t        | «      | j                  kD  r| j                  «        d d d «       y # 1 sw Y   y xY wr   )r5   r7   Ú__setitem__Úlenr0   Úfree_dead_references)r   r9   Ústorage_refs      r   r;   zSharedCache.__setitem__P   sL   € Ø�Y‰Yñ 	,Ü×Ñ˜T 3¨Ô4Ü�4‹y˜4Ÿ:™:Ò%Ø×)Ñ)Ô+÷	,÷ 	,ñ 	,ús   �A AÁAc                 ó¤   — d}t        | j                  «       «      D ]  \  }}|j                  «       r| |= Œ|dz  }Œ  t        d|dz  «      | _        y )Nr   é   r/   é   )ÚlistÚitemsr   Úmaxr0   )r   Úliver9   r>   s       r   r=   z SharedCache.free_dead_referencesV   sV   € ØˆÜ $ T§Z¡Z£\Ó 2ò 	ÑˆC�Ø×"Ñ"Ô$Ø˜‘Ià˜‘	‘ð		ô
 ˜˜d Q™hÓ'ˆ�
r   )ÚreturnN)	r%   r&   r'   r(   r   r1   r8   r;   r=   r+   r   r   r-   r-   <   s   „ ÙDó;ò%ò'ò,ó(r   r-   c                 óV   — t         j                  j                  j                  | |«      S r   )r   ÚcudaÚEventÚfrom_ipc_handle)ÚdeviceÚhandles     r   Úrebuild_eventrM   d   s   € Ü�:‰:×Ñ×+Ñ+¨F°FÓ;Ð;r   c                 óJ   — | j                  «       }t        | j                  |ffS r   )Ú
ipc_handlerM   rK   )ÚeventrL   s     r   Úreduce_eventrQ   h   s$   € Ø×ÑÓ€FÜ˜EŸL™L¨&Ð1Ð2Ð2r   c                 ó  — |\  }}}}t         j                  j                  ||||«      }| t         j                  j                  j
                  k(  r-t         j                  j                  j                  ||¬«      }|S ||_        |S )N©Úrequires_grad)r   Ú_utilsÚ_rebuild_tensorÚnnÚ	parameterÚ	ParameterrT   )r   r   ÚmetadataÚstorage_offsetÚsizeÚstriderT   Úts           r   Úrebuild_tensorr_   m   sx   € Ø2:Ñ/€N�D˜& -Ü�‰×$Ñ$ W¨n¸dÀFÓK€AØ
Œe�h‰h× Ñ ×*Ñ*Ò*ô �H‰H×Ñ×(Ñ(¨¸-Ð(ÓHˆð €Hð (ˆŒØ€Hr   c                 ó^  — t        j                  |d¬«      }t        j                  ||d¬«      }t         j                  j	                  ||||«      }	| t         j
                  j                  j                  k(  r-t         j
                  j                  j                  |	|¬«      }	|	S ||	_        |	S )NÚmeta©rK   T©Úwrap_storageÚdtypeÚ	_internalrS   )	r   ÚUntypedStorageÚTypedStoragerU   rV   rW   rX   rY   rT   )
Ú
tensor_clsÚtensor_sizeÚtensor_strideÚtensor_offsetre   Ústorage_size_bytesrT   Úuntyped_storageÚtyped_storager^   s
             r   Úrebuild_meta_tensorrp   z   s    € ô ×*Ñ*Ð+=ÀfÔM€Oä×&Ñ&Ø$¨E¸Tô€Mô 	�‰×$Ñ$ØØØØó		€Að ”U—X‘X×'Ñ'×1Ñ1Ò1ô �H‰H×Ñ×(Ñ(¨¸-Ð(ÓHˆð €Hð (ˆŒà€Hr   c           
      ó–  — |�|dk(  r |d||d¬«      }not        |||	f«      }|€Kt        j                  j                  «        |j	                  ||||	||||«      }t        |«      t        ||	f<   n|j                  |||¬«       t        |t        j                  «      r|n|j                  }t        j                  j                  t        j                  j                  ||d¬«      |||«      }| t        j                  j                   j"                  k(  r-t        j                  j                   j#                  ||
¬«      }|S |
|_        |S )Nr   T)re   rK   rf   rb   rc   rS   )Ústorage_from_cacher   rH   Ú
_lazy_initÚ_new_shared_cudar   Úshared_cacheÚ_release_ipc_counterÚ
isinstancerg   Ú_untyped_storagerU   rV   r   rh   rW   rX   rY   rT   )ri   rj   rk   rl   Ústorage_clsre   Ústorage_deviceÚstorage_handlerm   Ústorage_offset_bytesrT   Úref_counter_handleÚref_counter_offsetÚevent_handleÚevent_sync_requiredr   Ú_storager^   s                     r   Úrebuild_cuda_tensorr‚   š   s^  € ð$ ÐÐ!3°qÒ!8Ù˜a u°^ÈtÔT‰ä$Ø˜.Ð*>Ð?ó
ˆð ˆ?Ü�J‰J×!Ñ!Ô#Ø!×2Ñ2ØØØ"Ø$Ø"Ø"ØØ#ó	ˆGô DRØóDŒL˜.Ð*>Ð?Ò@ð
 ×,Ñ,Ø"Ð$6¸~ð -ô ô �gœu×3Ñ3Ô4ñ 	à×%Ñ%ð ô 	�‰×$Ñ$Ü�‰×"Ñ"°ÀÐQUÐ"ÓVØØØó		€Að ”U—X‘X×'Ñ'×1Ñ1Ò1ô �H‰H×Ñ×(Ñ(¨¸-Ð(ÓHˆð €Hð (ˆŒà€Hr   c                 ó  — | j                   r| j                  st        d«      ‚t        | «       t        j
                  j                  j                  | «       ddlm	} | j                  rt        | |«      st        | «      S | j                  t        j                  t        j                  t        j                   t        j"                  t        j$                  hv rt'        | «      S | j)                  «       }|j*                  j,                  j.                  dk(  r”|j1                  «       \  }}}}}}}	}
| j3                  «       }t5        |«      t6        |<   t8        t/        | «      | j;                  «       | j=                  «       |t/        |«      | j>                  ||||| j                   |||	|
ffS |j*                  j,                  j.                  dk(  rrt@        t/        | «      | j;                  «       | j=                  «       | j3                  «       | j>                  | jC                  «       j;                  «       | j                   ffS | j3                  «       | j;                  «       | j=                  «       | j                   f}tD        t/        | «      ||ffS )NzøCowardly refusing to serialize non-leaf tensor which requires_grad, since autograd does not support crossing process boundaries.  If you just want to transfer the data, call detach() on the tensor before serializing (e.g., putting it on the queue).r   )ÚNestedTensorrH   ra   )#rT   Úis_leafÚRuntimeErrorr   r   ÚutilsÚhooksÚwarn_if_has_hooksÚ$torch.nested._internal.nested_tensorr„   Ú	is_nestedrw   Úreduce_nested_tensorÚlayoutÚ
sparse_cooÚ
sparse_csrÚ
sparse_bsrÚ
sparse_cscÚ
sparse_bscÚreduce_sparse_tensorÚ_typed_storagerx   rK   ÚtypeÚ_share_cuda_r[   r   ru   r‚   r\   r]   re   rp   rn   r_   )Útensorr„   r   rK   rL   rm   r|   r}   r~   r   r€   rl   rZ   s                r   Úreduce_tensorr˜   Þ   sD  € Ø×Ò F§N¢NÜðBó
ð 	
ô # 6Ô*Ü	‡K�K×Ñ×'Ñ'¨Ô/õ~ Bà×Ò¤
¨6°<Ô @Ü# FÓ+Ð+à‡}�}Ü×ÑÜ×ÑÜ×ÑÜ×ÑÜ×Ñðñ ô $ FÓ+Ð+à×#Ñ#Ó%€Gà×Ñ×&Ñ&×+Ñ+¨vÒ5ð × Ñ Ó"ñ		
ØØØØ ØØØØà×-Ñ-Ó/ˆÜ-¨gÓ6Œ�VÑô  ä�V“Ø—‘“Ø—‘“ØÜ�W“Ø—‘ØØØ"Ø$Ø×$Ñ$Ø"Ø"ØØ#ðð
ð 	
ð( 
×	!Ñ	!×	(Ñ	(×	-Ñ	-°Ò	7ää�V“Ø—‘“Ø—‘“Ø×%Ñ%Ó'Ø—‘Ø×&Ñ&Ó(×-Ñ-Ó/Ø×$Ñ$ðð
ð 	
ð 	×ÑÓØ�‰‹Ø�‰‹Ø×Ñð	€Hô œT &›\¨7°HÐ=Ð>Ð>r   c                 óZ   —  | |Ž } ||Ž }	 ||Ž }
 ||Ž }t        j                  ||	|
|«      S r   )r   Ú_nested_view_from_buffer_copy)Úrebuild_buffer_funcÚrebuild_buffer_argsÚrebuild_sizes_funcÚrebuild_sizes_argsÚrebuild_strides_funcÚrebuild_strides_argsÚrebuild_offsets_funcÚrebuild_offsets_argsÚbufferÚsizesÚstridesÚoffsetss               r   Úrebuild_nested_tensorr§   ’  sG   € ñ !Ð"5Ð6€FÙÐ 2Ð3€EÙ"Ð$8Ð9€GÙ"Ð$8Ð9€GÜ×.Ñ.¨v°u¸gÀwÓOÐOr   c           	      ó  — t        | j                  «       «      \  }}t        | j                  «       «      \  }}t        | j                  «       «      \  }}t        | j	                  «       «      \  }}t
        ||||||||ffS r   )r˜   ÚvaluesÚ_nested_tensor_sizeÚ_nested_tensor_stridesÚ_nested_tensor_storage_offsetsr§   )	Úntr›   rœ   r�   rž   rŸ   r    r¡   r¢   s	            r   rŒ   rŒ   £  s›   € Ü/<¸R¿Y¹Y»[Ó/IÑ,ÐÐ,Ü-:¸2×;QÑ;QÓ;SÓ-TÑ*ÐÐ*Ü1>Ø
×!Ñ!Ó#ó2Ñ.ÐÐ.ô 2?Ø
×)Ñ)Ó+ó2Ñ.ÐÐ.ô
 	àØØØØ Ø Ø Ø ð		
ðð r   c                 óH   —  | |Ž } ||Ž }t        j                  ||||¬«      S )N)Úis_coalesced)r   Úsparse_coo_tensor)Úrebuild_indices_funcÚrebuild_indices_argsÚrebuild_values_funcÚrebuild_values_argsÚshaper¯   Úindicesr©   s           r   Úrebuild_sparse_coo_tensorr·   ¼  s1   € ñ #Ð$8Ð9€GÙ Ð"5Ð6€FÜ×"Ñ" 7¨F°EÈÔUÐUr   c                 óT   —  | |Ž } ||Ž }	 ||Ž }
t        j                  ||	|
||¬«      S )N)r�   )r   Úsparse_compressed_tensor)Úrebuild_compressed_indices_funcÚrebuild_compressed_indices_argsÚrebuild_plain_indices_funcÚrebuild_plain_indices_argsr³   r´   rµ   r�   Úcompressed_indicesÚplain_indicesr©   s              r   Ú rebuild_sparse_compressed_tensorrÀ   É  sH   € ñ 9Ø	(ðÐñ /Ð0JÐK€MÙ Ð"5Ð6€FÜ×)Ñ)Ø˜M¨6°5Àôð r   c           	      ó  — | j                   t        j                  u r^t        | j	                  «       «      \  }}t        | j                  «       «      \  }}t        ||||| j                  | j                  «       ffS | j                   t        j                  t        j                  hv r!| j                  «       }| j                  «       }nb| j                   t        j                  t        j                  hv r!| j                  «       }| j!                  «       }nt#        | j                   «      ‚t        |«      \  }}t        |«      \  }	}
t        | j%                  «       «      \  }}t&        |||	|
||| j                  | j                   ffS r   )r�   r   rŽ   r˜   Ú_indicesÚ_valuesr·   rµ   r¯   r�   r�   Úcrow_indicesÚcol_indicesr‘   r’   Úccol_indicesÚrow_indicesÚNotImplementedErrorr©   rÀ   )Úsparser±   r²   r³   r´   r¾   r¿   rº   r»   r¼   r½   s              r   r“   r“   Ý  sq  € Ø‡}�}œ×(Ñ(Ñ(Ü5BÀ6Ç?Á?ÓCTÓ5UÑ2ÐÐ2Ü3@ÀÇÁÓAQÓ3RÑ0ÐÐ0ä%à$Ø$Ø#Ø#Ø—‘Ø×#Ñ#Ó%ðð

ð 
	
ð �=‰=œU×-Ñ-¬u×/?Ñ/?Ð@Ñ@Ø!'×!4Ñ!4Ó!6ÐØ"×.Ñ.Ó0‰MØ�]‰]œu×/Ñ/´×1AÑ1AÐBÑBØ!'×!4Ñ!4Ó!6ÐØ"×.Ñ.Ó0‰Mä% f§m¡mÓ4Ð4ô Ð,Ó-ñ	
Ø+Ø+äANØóB
Ñ>Ð"Ð$>ô 4AÀÇÁÃÓ3QÑ0ÐÐ0ä,à/Ø/Ø*Ø*Ø#Ø#Ø—‘Ø—‘ð	ð
ð 	
r   c                 ó\   — t        j                  | «      }|j                  |j                  fS r   )ÚosÚfstatÚst_inoÚst_dev)ÚfdÚstats     r   Úfd_idrÑ     s$   € ô �8‰8�B‹<€DØ�K‰K˜Ÿ™Ð%Ð%r   c                 ó„   — t         j                  |«      }|€y t        j                  j	                  |j
                  «      S r   )ru   r8   r   rg   Ú_new_with_weak_ptrr   )r   r9   r>   s      r   rr   rr     s8   € Ü×"Ñ" 3Ó'€KØÐØÜ×Ñ×2Ñ2°;×3DÑ3DÓEÐEr   c                 ó<  — |j                  «       }	 t        | t        |«      «      }|�|t        j                  |«       S | j                  ||«      }t        |«      t        t        |«      <   |t        j                  |«       S # t        j                  |«       w xY wr   )Údetachrr   rÑ   rË   ÚcloseÚ_new_shared_fd_cpur   ru   )r   Údfr\   rÏ   r   s        r   Úrebuild_storage_fdrÙ     sy   € Ø	�‰‹€BðÜ$ S¬%°«)Ó4ˆØÐØô
 	�‰��ð	 ×(Ñ(¨¨TÓ2ˆÜ"0°Ó"9Œ”U˜2“YÑØä
�‰��øŒ�‰��ús   ’B Á .B ÂBc                 ó€  — t        | |«      }|�|j                  «       S |€"t        j                  j	                  |||«      }n[|t        j
                  j                  |«      z  }t        j                  j	                  |||«      }t        j                  ||d¬«      }t        |«      t        |<   |j                  «       S ©NTrc   )
rr   Ú_shared_decrefr   rg   Ú_new_shared_filename_cpurU   Ú_element_sizerh   r   ru   )r   ÚmanagerrL   r\   re   r   Ú	byte_sizern   s           r   Úrebuild_storage_filenamerá   (  s³   € Ü9KÈCÐQWÓ9X€GØÐØ×%Ñ%Ó'Ð'Ø€}Ü×&Ñ&×?Ñ?ÀÈÐQUÓV‰àœ5Ÿ<™<×5Ñ5°eÓ<Ñ<ˆ	ä× Ñ ×9Ñ9¸'À6È9ÓUð 	ô ×$Ñ$Ø(°Àô
ˆô *¨'Ó2„L�ÑØ×!Ñ!Ó#Ð#r   c                 ó   —  | «       S r   r+   )r   s    r   Úrebuild_storage_emptyrã   :  s	   € Ù‹5€Lr   c                 óF   — t         j                  j                  | |d¬«      S rÛ   )r   r   rh   )r   re   s     r   Úrebuild_typed_storagerå   >  s   € Ü�=‰=×%Ñ%°7À%ÐSWÐ%ÓXÐXr   c                 ó>   — t         | j                  | j                  ffS r   )rå   rx   re   ©r   s    r   Úreduce_typed_storagerè   C  s   € Ü! G×$<Ñ$<¸g¿m¹mÐ#LÐMÐMr   c                 ó   —  || d¬«      S )NT)rd   rf   r+   )r   Ústorage_types     r   Úrebuild_typed_storage_childrë   G  s   € Ù W¸Ô=Ð=r   c                 ó<   — t         | j                  t        | «      ffS r   )rë   rx   r•   rç   s    r   Úreduce_typed_storage_childrí   L  s   € Ü'¨'×*BÑ*BÄDÈÃMÐ)RÐSÐSr   c                 ób  — ddl m} | j                  rt        d«      ‚| j                  j
                  dk(  rt        d«      ‚ |«       dk(  rV| j                  «       }|d   }t        }t        | t        j                  «      r|| j                  fz  }| j                  «        nl| j                  «       dk(  rt        t        | «      ffS | j                  «       \  }}t         j"                  j%                  |«      }t'        |«      }||f}t(        }t+        | «      t,        |<   |t        | «      f|z   fS )Nr@   )Úget_sharing_strategyz>Cannot pickle CUDA storage; try pickling a CUDA tensor insteadra   z>Cannot pickle meta storage; try pickling a meta tensor insteadÚfile_systemr   )Ú rï   Úis_cudar†   rK   r•   Ú_share_filename_cpu_rá   rw   r   rh   re   Ú_shared_increfr\   rã   Ú_share_fd_cpu_Úmultiprocessingr   ÚDupFdrÑ   rÙ   r   ru   )r   rï   rZ   Ú	cache_keyÚrebuildrÏ   r\   rØ   s           r   Úreduce_storagerú   P  s  € Ý&à‡‚ÜØLó
ð 	
ð 
�‰×	Ñ	 Ò	&ÜØLó
ð 	
ñ 
Ó	 =Ò	0Ø×/Ñ/Ó1ˆØ˜Q‘Kˆ	Ü*ˆÜ�gœu×1Ñ1Ô2Ø˜Ÿ™Ð(Ñ(ˆHØ×ÑÕ Ø	�‰‹˜1Ò	ô &¬¨W«Ð'7Ð8Ð8à×)Ñ)Ó+‰ˆˆDÜ×&Ñ&×,Ñ,¨RÓ0ˆÜ˜"“Iˆ	Ø˜�:ˆÜ$ˆä,¨WÓ5„L�ÑØ”d˜7“mÐ%¨Ñ0Ð1Ð1r   c                  ól  — t        j                  t        j                  j                  t
        «       t        j                  D ]F  } | j                  dk(  rt        j                  | t        «       Œ-t        j                  | t        «       ŒH t        j                  t        j                  j                  t        «       t        j                  D ]  } t        j                  | t        «       Œ t        j                  t        j                  t        «       ddlm} t        j                  |t        «       y )Nrg   r   )rY   )r   Úregisterr   rH   rI   rQ   Ú_storage_classesr%   rú   rí   r   rh   rè   Ú_tensor_classesr˜   ÚTensorÚtorch.nn.parameterrY   )r^   rY   s     r   Úinit_reductionsr  q  sÊ   € Ü×Ñ”u—z‘z×'Ñ'¬Ô6ä×#Ñ#ò >ˆØ�:‰:Ð)Ò)Ü×Ñ˜q¤.Õ1ä×Ñ˜qÔ"<Õ=ð	>ô ×Ñ”u—}‘}×1Ñ1Ô3GÔHä×"Ñ"ò -ˆÜ×Ñ˜1œmÕ,ð-ô ×Ñ”u—|‘|¤]Ô3å,ä×Ñ�y¤-Õ0r   r   )%rö   rË   r3   r   Úmultiprocessing.utilr   r   Útorch._namedtensor_internalsr   Úmultiprocessing.resource_sharerÚImportErrorr   r7   r-   ru   rM   rQ   r_   rp   r‚   r˜   r§   rŒ   r·   rÀ   r“   rÑ   rr   rÙ   rá   rã   rå   rè   rë   rí   rú   r  r+   r   r   ú<module>r     sÕ   ðã Û 	Û Ý %Ý 4ã Ý Gð	ó +÷
")ñ ")ôJ!(�$ô !(ñJ ‹}€ò<ò3ò

òò@AòHq?òhPò"ò2
Vòò(,
ò^&òFò
ó$ò$òYò
Nò>ò
Tò2óB1øð} ò 	Ùð	ús   ¤B ÂBÂB