Ë
    [^(h  ã                   ó:  — d dl mZ d dl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
j2                  f      ded
ee
j.                  df   fd„«       Ze	 ddedeeee
j2                  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
j2                  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
j2                  f   ded
efd„Zy)é    )ÚSequence)ÚAnyÚOptionalÚoverloadÚ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    ú^/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/nn/parallel/scatter_gather.pyÚis_namedtupler      s   € ô ˜#ÓÐó    c                 óZ   — t        | t        «      xr t        | d«      xr t        | d«      S )NÚ_asdictÚ_fields)Ú
isinstanceÚtupleÚhasattrr   s    r   r   r      s+   € ô 	�3œÓÒV¤7¨3°	Ó#:ÒV¼wÀsÈIÓ?Vðr   ÚT.ÚinputsÚtarget_gpusÚdimc                  ó   — y r   © ©r    r!   r"   s      r   r   r   !   ó   € ð r   c                  ó   — y r   r$   r%   s      r   r   r   *   r&   r   c                 ó>   ‡‡‡— ˆˆˆfd„Š	  ‰| «      }dŠ|S # dŠw xY w)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,t        t        ‰| «      Ž D �cg c]  } t        | «      |Ž ‘Œ c}S t        | t        «      r)t        | «      dkD  rt        t        t        ‰| «      Ž «      S t        | t        «      r7t        | «      dkD  r)t        t        ‰| «      Ž D �cg c]  }t        |«      ‘Œ c}S t        | t        «      rKt        | «      dkD  r=t        t        ‰| j                  «       «      Ž D �cg c]  } t        | «      |«      ‘Œ c}S ‰D �cg c]  }| ‘Œ c}S c c}w c c}w c c}w c c}w )Nr   )r   ÚtorchÚTensorr   Úapplyr   ÚzipÚmapÚtyper   ÚlenÚlistÚdictÚitems)r   ÚargsÚiÚ_r"   Úscatter_mapr!   s       €€€r   r7   zscatter.<locals>.scatter_map9   s  ø€ Ü�cœ5Ÿ<™<Ô(Ü—=‘= ¨d°C¸Ó=Ð=Ü˜#ÔÜ14´c¸+ÀsÓ6KÐ1LÖM¨�I”D˜“I˜tÒ$ÒMÐMÜ�cœ5Ô!¤c¨#£h°¢lÜœœS ¨cÓ2Ð3Ó4Ð4Ü�cœ4Ô ¤S¨£X°¢\Ü%(¬#¨k¸3Ó*?Ð%@ÖA ”D˜•GÒAÐAÜ�cœ4Ô ¤S¨£X°¢\Ü*-¬s°;ÀÇ	Á	ÃÓ/LÐ*MÖN Q�I”D˜“I˜a•LÒNÐNØ(Ö)˜’Ò)Ð)ùò Nùò BùâNùÚ)s   ÁEÃEÄ+E Å
	E%Nr$   )r    r!   r"   Úresr7   s    `` @r   r   r   3   s*   ú€ ö*ð$Ù˜&Ó!ˆàˆØ€Jøð ‰úó   Œ ˜Úkwargsc           	      ó¨  — | rt        | ||«      ng }|rt        |||«      ng }t        |«      t        |«      k  r7|j                  d„ t        t        |«      t        |«      z
  «      D «       «       nMt        |«      t        | «      k  r6|j                  d„ t        t        |«      t        |«      z
  «      D «       «       t	        |«      t	        |«      fS )z+Scatter with support for kwargs dictionary.c              3   ó    K  — | ]  }d –— Œ y­w)r$   Nr$   ©Ú.0r6   s     r   ú	<genexpr>z!scatter_kwargs.<locals>.<genexpr>\   ó   è ø€ ò  
ØŒBñ 
ùó   ‚c              3   ó    K  — | ]  }i –— Œ y ­wr   r$   r=   s     r   r?   z!scatter_kwargs.<locals>.<genexpr>`   r@   rA   )r   r0   ÚextendÚranger   )r    r:   r!   r"   Úscattered_inputsÚscattered_kwargss         r   r   r   R   sÎ   € ñ =C”w˜v {°CÔ8ÈÐÙ<B”w˜v {°CÔ8ÈÐÜ
ÐÓœsÐ#3Ó4Ò4Ø×Ññ  
ÜœcÐ"2Ó3´cÐ:JÓ6KÑKÓLô 
õ 	
ô 
ÐÓ	¤ V£Ò	,Ø×Ññ  
ÜœcÐ"2Ó3´cÐ:JÓ6KÑKÓLô 
ô 	
ô Ð!Ó"¤EÐ*:Ó$;Ð;Ð;r   ÚoutputsÚtarget_devicec                 ó>   ‡‡‡— ˆˆˆfd„Š	  ‰| «      }dŠ|S # dŠw xY w)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‰ ¢­Ž S ‰€y t        ‰t
        «      r:t        ˆfd„‰ D «       «      st        d«      ‚ t        ‰«      ˆˆ fd„‰D «       «      S t        ‰«      r*t        ‰«      j                  t        ‰t        ‰ Ž «      «      S  t        ‰«      t        ‰t        ‰ Ž «      «      S )Nr   c              3   óL   •K  — | ]  }t        ‰«      t        |«      k(  –— Œ y ­wr   )r0   )r>   ÚdÚouts     €r   r?   z-gather.<locals>.gather_map.<locals>.<genexpr>~   s   øè ø€ Ò;¨a”s˜3“x¤3 q£6Õ)Ñ;ùs   ƒ!$z+All dicts must have the same number of keysc           	   3   ó^   •K  — | ]  }| ‰‰D �cg c]  }||   ‘Œ	 c}«      f–— Œ! y c c}w ­wr   r$   )r>   ÚkrL   Ú
gather_maprG   s      €€r   r?   z-gather.<locals>.gather_map.<locals>.<genexpr>€   s-   øè ø€ ÒSÈ!˜a¡¸7Ö,C°a¨Q¨q«TÒ,CÓ!DÔEÑSùÒ,Cùs   ƒ-�(›-)r   r*   r+   r
   r,   r2   ÚallÚ
ValueErrorr/   r   Ú_maker.   r-   )rG   rM   r"   rP   rH   s   `@€€€r   rP   zgather.<locals>.gather_mapw   sµ   ú€ Ø�a‰jˆÜ�cœ5Ÿ<™<Ô(Ü—<‘< ¨sÐ=°WÒ=Ð=Øˆ;ØÜ�cœ4Ô ÜÓ;°7Ô;Ô;Ü Ð!NÓOÐOØ”4˜“9ÔSÈsÔSÓSÐSÜ˜#ÔÜ˜“9—?‘?¤3 z´3¸°=Ó#AÓBÐBØŒt�C‹yœ˜Z¬¨g¨Ó7Ó8Ð8r   Nr$   )rG   rH   r"   r8   rP   s    `` @r   r   r   f   s*   ú€ ö"9ð Ù˜Ó!ˆàˆ
Ø€Jøð ‰
úr9   ).)r   )Úcollections.abcr   Útypingr   r   r   r   r   Útyping_extensionsr	   r*   Útorch.nn.parallel._functionsr
   r   Ú__all__ÚFutureWarningÚboolr   r   r2   r1   r   r   r+   ÚintÚdevicer   Ústrr   r   r$   r   r   ú<module>r^      sà  ðå $ß :Õ :Ý (ã ß 8ò 2€ñ ØIØôð�sð ˜tò ó	ðð
˜ð  ó ñ ˆC��t˜UÓ#€ð 
ð ñØ�L‰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   