§
    Ë²Åj  ã                   ó‚  — d dl mZmZmZmZmZmZmZmZm	Z	 d dl
mZ d dlZd dlmZmZ g d¢Z ede¬¦  «        ded	efd
„¦   «         Zded	efd„Z edeee¦  «        Ze	 ddej        dee	eej        f                  ded	eej        df         fd„¦   «         Ze	 ddedee	eej        f                  ded	ee         fd„¦   «         Zdd„Z	 ddeedf         deeeef                  dee	eej        f                  ded	eeedf         eeeef         df         f         f
d„Zddede	eej        f         ded	efd„ZdS )é    )	ÚAnyÚDictÚListÚOptionalÚoverloadÚSequenceÚTupleÚTypeVarÚUnion)Ú
deprecatedN)ÚGatherÚScatter)ÚscatterÚscatter_kwargsÚgatherzC`is_namedtuple` is deprecated, please use the python checks instead)ÚcategoryÚobjÚreturnc                 ó    — t          | ¦  «        S ©N)Ú_is_namedtuple©r   s    úQC:\Projects\Historical\venv\Lib\site-packages\torch/nn/parallel/scatter_gather.pyÚis_namedtupler      s   € õ ˜#ÑÔÐó    c                 ól   — t          | t          ¦  «        ot          | d¦  «        ot          | d¦  «        S )NÚ_asdictÚ_fields)Ú
isinstanceÚtupleÚhasattrr   s    r   r   r      s4   € õ 	�3�ÑÔÐV¥7¨3°	Ñ#:Ô#:ÐV½wÀsÈIÑ?VÔ?Vðr   ÚT.ÚinputsÚtarget_gpusÚdimc                 ó   — d S r   © ©r#   r$   r%   s      r   r   r       ó	   € ð €Cr   c                 ó   — d S r   r'   r(   s      r   r   r   )   r)   r   c                 óF   ‡‡‡— ˆˆˆfd„Š	  ‰| ¦  «        }dŠn# dŠw xY w|S )z–Slice tensors into approximately equal chunks and distributes them across given GPUs.

    Duplicates references to objects that are not tensors.
    c                 óÌ  •‡ — t          ‰ t          j        ¦  «        rt          j        ‰d ‰‰ ¦  «        S t          ‰ ¦  «        r#ˆ fd„t          t          ‰‰ ¦  «        Ž D ¦   «         S t          ‰ t          ¦  «        r7t          ‰ ¦  «        dk    r$t          t          t          ‰‰ ¦  «        Ž ¦  «        S t          ‰ t          ¦  «        r4t          ‰ ¦  «        dk    r!d„ t          t          ‰‰ ¦  «        Ž D ¦   «         S t          ‰ t          ¦  «        rHt          ‰ ¦  «        dk    r5ˆ fd„t          t          ‰‰                      ¦   «         ¦  «        Ž D ¦   «         S ˆ fd„‰D ¦   «         S )Nc                 ó4   •— g | ]} t          ‰¦  «        |Ž ‘ŒS r'   ©Útype)Ú.0Úargsr   s     €r   ú
<listcomp>z0scatter.<locals>.scatter_map.<locals>.<listcomp><   s&   ø€ ÐMÐMÐM¨�I•D˜‘I”I˜tÐ$ÐMÐMÐMr   r   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r'   )Úlist)r0   Úis     r   r2   z0scatter.<locals>.scatter_map.<locals>.<listcomp>@   s   € ÐAÐAÐA •D˜‘G”GÐAÐAÐAr   c                 ó@   •— g | ]} t          ‰¦  «        |¦  «        ‘ŒS r'   r.   )r0   r5   r   s     €r   r2   z0scatter.<locals>.scatter_map.<locals>.<listcomp>B   s'   ø€ ÐNÐNÐN Q�I•D˜‘I”I˜a‘L”LÐNÐNÐNr   c                 ó   •— g | ]}‰‘ŒS r'   r'   )r0   Ú_r   s     €r   r2   z0scatter.<locals>.scatter_map.<locals>.<listcomp>C   s   ø€ Ð)Ð)Ð)˜�Ð)Ð)Ð)r   )r   ÚtorchÚTensorr   Úapplyr   ÚzipÚmapr    Úlenr4   ÚdictÚitems)r   r%   Úscatter_mapr$   s   `€€€r   rA   zscatter.<locals>.scatter_map8   sU  øø€ Ý�c�5œ<Ñ(Ô(ð 	>Ý”= ¨d°C¸Ñ=Ô=Ð=Ý˜#ÑÔð 	NØMÐMÐMÐMµµc¸+ÀsÑ6KÔ6KÐ1LÐMÑMÔMÐMÝ�c�5Ñ!Ô!ð 	5¥c¨#¡h¤h°¢l lÝ��S ¨cÑ2Ô2Ð3Ñ4Ô4Ð4Ý�c�4Ñ Ô ð 	B¥S¨¡X¤X°¢\ \ØAÐA¥S­#¨k¸3Ñ*?Ô*?Ð%@ÐAÑAÔAÐAÝ�c�4Ñ Ô ð 	O¥S¨¡X¤X°¢\ \ØNÐNÐNÐN­#­s°;ÀÇ	Â	ÁÄÑ/LÔ/LÐ*MÐNÑNÔNÐNØ)Ð)Ð)Ð)˜[Ð)Ñ)Ô)Ð)r   Nr'   )r#   r$   r%   ÚresrA   s    `` @r   r   r   2   sY   øøø€ ð*ð *ð *ð *ð *ð *ð *ð$Øˆk˜&Ñ!Ô!ˆàˆˆø�dˆÐÐÐÐØ€Jó   Œ šÚkwargsc           	      ó8  — | rt          | ||¦  «        ng }|rt          |||¦  «        ng }t          |¦  «        t          |¦  «        k     rJ|                     d„ t          t          |¦  «        t          |¦  «        z
  ¦  «        D ¦   «         ¦  «         nit          |¦  «        t          | ¦  «        k     rI|                     d„ t          t          |¦  «        t          |¦  «        z
  ¦  «        D ¦   «         ¦  «         t	          |¦  «        t	          |¦  «        fS )z+Scatter with support for kwargs dictionary.c              3   ó   K  — | ]}d V — ŒdS )r'   Nr'   ©r0   r8   s     r   ú	<genexpr>z!scatter_kwargs.<locals>.<genexpr>[   ó3   è è € ð  
ð  
ØˆBð 
ð  
ð  
ð  
ð  
ð  
r   c              3   ó   K  — | ]}i V — Œd S r   r'   rG   s     r   rH   z!scatter_kwargs.<locals>.<genexpr>_   rI   r   )r   r>   ÚextendÚranger    )r#   rD   r$   r%   Úscattered_inputsÚscattered_kwargss         r   r   r   Q   s@  € ð =CÐJ•w˜v {°CÑ8Ô8Ð8ÈÐØ<BÐJ•w˜v {°CÑ8Ô8Ð8ÈÐÝ
ÐÑÔ�sÐ#3Ñ4Ô4Ò4Ð4Ø×Òð  
ð  
Ý�cÐ"2Ñ3Ô3µcÐ:JÑ6KÔ6KÑKÑLÔLð 
ñ  
ô  
ñ 	
ô 	
ð 	
ð 	
õ 
ÐÑ	Ô	¥ V¡¤Ò	,Ð	,Ø×Òð  
ð  
Ý�cÐ"2Ñ3Ô3µcÐ:JÑ6KÔ6KÑKÑLÔLð 
ñ  
ô  
ñ 	
ô 	
ð 	
õ Ð!Ñ"Ô"¥EÐ*:Ñ$;Ô$;Ð;Ð;r   ÚoutputsÚtarget_devicec                 óF   ‡‡‡— ˆˆˆfd„Š	  ‰| ¦  «        }dŠn# dŠw xY w|S )a™  Gather tensors from different GPUs on a specified device.

    This function is useful for gathering the results of a distributed computation.
    It takes a sequence of objects, one for each GPU, and returns a single object
    on the specified device.

    Args:
        outputs (Any): A sequence of objects (potentially tensors) to gather.
        target_device (Union[int, torch.device]): The device to gather the tensors to.
            Use 'cpu' for CPU to avoid a deprecation warning.
        dim (int, optional): The dimension along which to gather. Default: 0.

    Returns:
        Any: A gathered object (potentially tensor) on the specified device.
    c                 ó(  •‡ ‡— ‰ d         Št          ‰t          j        ¦  «        rt          j        ‰‰g‰ ¢R Ž S ‰€d S t          ‰t
          ¦  «        rOt          ˆfd„‰ D ¦   «         ¦  «        st          d¦  «        ‚ t          ‰¦  «        ˆˆ fd„‰D ¦   «         ¦  «        S t          ‰¦  «        r7t          ‰¦  «         
                    t          ‰t          ‰ Ž ¦  «        ¦  «        S  t          ‰¦  «        t          ‰t          ‰ Ž ¦  «        ¦  «        S )Nr   c              3   óX   •K  — | ]$}t          ‰¦  «        t          |¦  «        k    V — Œ%d S r   )r>   )r0   ÚdÚouts     €r   rH   z-gather.<locals>.gather_map.<locals>.<genexpr>}   s4   øè è € Ð;Ð;¨a•s˜3‘x”x¥3 q¡6¤6Ò)Ð;Ð;Ð;Ð;Ð;Ð;r   z+All dicts must have the same number of keysc              3   óL   •‡K  — | ]Š‰ ‰ˆfd „‰D ¦   «         ¦  «        fV — ŒdS )c                 ó    •— g | ]
}|‰         ‘ŒS r'   r'   )r0   rT   Úks     €r   r2   z8gather.<locals>.gather_map.<locals>.<genexpr>.<listcomp>   s   ø€ Ð,CÐ,CÐ,C°a¨Q¨q¬TÐ,CÐ,CÐ,Cr   Nr'   )r0   rX   Ú
gather_maprO   s    @€€r   rH   z-gather.<locals>.gather_map.<locals>.<genexpr>   sH   øøè è € ÐSÐSÈ!˜a  Ð,CÐ,CÐ,CÐ,C¸7Ð,CÑ,CÔ,CÑ!DÔ!DÐEÐSÐSÐSÐSÐSÐSr   )r   r9   r:   r   r;   r?   ÚallÚ
ValueErrorr/   r   Ú_maker=   r<   )rO   rU   r%   rY   rP   s   `@€€€r   rY   zgather.<locals>.gather_mapv   s  øøø€ Ø�aŒjˆÝ�c�5œ<Ñ(Ô(ð 	>Ý”< ¨sÐ=°WÐ=Ð=Ð=Ð=Øˆ;Ø�4Ý�c�4Ñ Ô ð 	TÝÐ;Ð;Ð;Ð;°7Ð;Ñ;Ô;Ñ;Ô;ð PÝ Ð!NÑOÔOÐOØ•4˜‘9”9ÐSÐSÐSÐSÐSÈsÐSÑSÔSÑSÔSÐSÝ˜#ÑÔð 	CÝ˜‘9”9—?’?¥3 zµ3¸°=Ñ#AÔ#AÑBÔBÐBØ�t�C‰yŒy�˜Z­¨g¨Ñ7Ô7Ñ8Ô8Ð8r   Nr'   )rO   rP   r%   rB   rY   s    `` @r   r   r   e   sY   øøø€ ð"9ð 9ð 9ð 9ð 9ð 9ð 9ð Øˆj˜Ñ!Ô!ˆàˆ
ˆ
ø�Tˆ
ÐÐÐÐØ€JrC   ).)r   ) Útypingr   r   r   r   r   r   r	   r
   r   Útyping_extensionsr   r9   Útorch.nn.parallel._functionsr   r   Ú__all__ÚFutureWarningÚboolr   r   r?   r4   r    r"   r:   ÚintÚdevicer   Ústrr   r   r'   r   r   ú<module>rf      sÏ  ðà WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WØ (Ð (Ð (Ð (Ð (Ð (à €€€Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ð 2Ð
1Ð
1€ð €ØIØðñ ô ð�sð ˜tð ð ð ñ	ô ðð
˜ð  ð ð ð ð ð €GˆC��t˜UÑ#Ô#€ð 
ð ðð ØŒLðà˜%  U¤\Ð 1Ô2Ô3ðð 
ðð ˆ5Œ<˜ÐÔð	ð ð ñ 
„ðð 
ð ðð Øðà˜%  U¤\Ð 1Ô2Ô3ðð 
ðð 
ˆ!„Wð	ð ð ñ 
„ððð ð ð ðF ð	<ð <Ø�#�s�(ŒOð<à�T˜#˜s˜(”^Ô$ð<ð ˜%  U¤\Ð 1Ô2Ô3ð<ð 
ð	<ð
 ˆ5��c�Œ?˜E $ s¨C x¤.°#Ð"5Ô6Ð6Ô7ð<ð <ð <ð <ð(%ð %�Cð %¨¨c°5´<Ð.?Ô(@ð %Àsð %ÐSVð %ð %ð %ð %ð %ð %r   