+
    ˜°³jg0  ã                   ó*  € ^ RI Ht ^ RIHtHtHt ^ RIHtHtH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt . ROt]	! R
RR7      tR R lt]! R4       ! R R]],          4      4       t]! R4       ! R R	]4      4       t]! R4       ! R R]],          4      4       tR# )é    )Údefaultdict)ÚCallableÚIteratorÚSized)ÚAnyÚNoReturnÚTypeVar)Úfunctional_datapipe)Ú	DataChunkÚIterDataPipe)Ú_check_unpickable_fnÚBatcherIterDataPipeÚGrouperIterDataPipeÚUnBatcherIterDataPipeÚ_T_coT)Ú	covariantc                ó0   € V ^8„  d   QhR\         R\        /# )é   ÚnameÚreturn)Ústrr   )Úformats   "Úi/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/utils/data/datapipes/iter/grouping.pyÚ__annotate__r      s   € ÷ Gñ G”cð Gœhñ Gó    c                 ó,   € \        R \         RV  24      h)zmodule z has no attribute )ÚAttributeErrorÚ__name__)r   s   &r   Ú__getattr__r      s   € Ü
˜7¤8 *Ð,>¸t¸fÐEÓ
FÐFr   Úbatchc                   óz   a a€ ] tR t^t oRtR]3V3R lV 3R llltV3R lR ltV3R lR ltV3R	 lt	R
t
VtV ;t# )r   aî  
Creates mini-batches of data (functional name: ``batch``).

An outer dimension will be added as ``batch_size`` if ``drop_last`` is set to ``True``, or ``length % batch_size`` for the
last batch if ``drop_last`` is set to ``False``.

Args:
    datapipe: Iterable DataPipe being batched
    batch_size: The size of each batch
    drop_last: Option to drop the last batch if it's not full
    wrapper_class: wrapper to apply onto each batch (type ``List``) before yielding,
        defaults to ``DataChunk``

Example:
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import IterableWrapper
    >>> dp = IterableWrapper(range(10))
    >>> dp = dp.batch(batch_size=3, drop_last=True)
    >>> list(dp)
    [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
Fc          
      óF   <€ V ^8„  d   QhRS[ RS[RS[RS[S[,          RR/# )r   ÚdatapipeÚ
batch_sizeÚ	drop_lastÚwrapper_classr   N)r   ÚintÚboolÚtyper   )r   Ú__classdict__s   "€r   r   Ú BatcherIterDataPipe.__annotate__5   sA   ø€ ÷ +ñ +áð+ñ ð+ñ ð	+ñ
 ™I•ð+ð 
ñ+r   c                óx   <€ V^ 8:  d   \        R4      h\        SV `	  4        Wn        W n        W0n        W@n        R# )r   z+Batch size is required to be larger than 0!N)ÚAssertionErrorÚsuperÚ__init__r#   r$   r%   r&   )Úselfr#   r$   r%   r&   Ú	__class__s   &&&&&€r   r/   ÚBatcherIterDataPipe.__init__5   s8   ø€ ð ˜Œ?Ü Ð!NÓOÐOÜ‰ÑÔØ ŒØ$ŒØ"ŒØ*Ör   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r   r   )r   r   )r   r*   s   "€r   r   r+   D   s   ø€ ÷ 	0ñ 	0™(¡9Õ-ñ 	0r   c              #  ó.  "  € . pV P                    FE  pVP                  V4       \        V4      V P                  8X  g   K0  V P	                  V4      x € . pKG  	  \        V4      ^ 8”  d*   V P
                  '       g   V P	                  V4      x € R# R# R# 5i©r   N)r#   ÚappendÚlenr$   r&   r%   )r0   r    Úxs   &  r   Ú__iter__ÚBatcherIterDataPipe.__iter__D   sz   é € ØˆØ—”ˆAØ�L‰L˜ŒOÜ�5‹z˜TŸ_™_Ö,Ø×(Ñ(¨Ó/Ò/Ø’ñ	 ô
 ˆu‹:˜Œ>Ø—>—>�>Ø×(Ñ(¨Ó/Ô/ñ "ñ ùs   ‚:BÁ:BÁ<Bc                ó    <€ V ^8„  d   QhRS[ /# r4   )r'   )r   r*   s   "€r   r   r+   O   s   ø€ ÷ Yñ Y™ñ Yr   c                óp  € \        V P                  \        4      '       dw   V P                  '       d'   \	        V P                  4      V P
                  ,          # \	        V P                  4      V P
                  ,           ^,
          V P
                  ,          # \        \        V 4      P                   R24      h)é   z# instance doesn't have valid length)	Ú
isinstancer#   r   r%   r8   r$   Ú	TypeErrorr)   r   ©r0   s   &r   Ú__len__ÚBatcherIterDataPipe.__len__O   sx   € ä�d—m‘m¤U×+Ò+Ø�~�~ˆ~Ü˜4Ÿ=™=Ó)¨T¯_©_Õ<Ð<ä˜DŸM™MÓ*¨T¯_©_Õ<¸qÕ@ÀTÇ_Á_ÕTÐTäœt D›z×2Ñ2Ð3Ð3VÐWÓXÐXr   c                ó>   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   # )r   r#   r$   r%   )r   r'   r(   )r   r*   s   "€r   r   r+      s*   ø‡ ‚ ñ0 Ññ1 ñ2 �Oñ3 ñ4 �Oò5 r   )r$   r#   r%   r&   )r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r/   r:   rB   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r1   r*   s   @@r   r   r      s:   ù‡ € ñð<  Ø)2÷+õ +÷	0ð 	0÷Yð Y÷m … r   Úunbatchc                   óF   a € ] tR t^Zt o RtRV 3R lR lltR tR tRtV t	R# )	r   aÝ  
Undoes batching of data (functional name: ``unbatch``).

In other words, it flattens the data up to the specified level within a batched DataPipe.

Args:
    datapipe: Iterable DataPipe being un-batched
    unbatch_level: Defaults to ``1`` (only flattening the top level). If set to ``2``,
        it will flatten the top two levels, and ``-1`` will flatten the entire DataPipe.

Example:
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import IterableWrapper
    >>> source_dp = IterableWrapper([[[0, 1], [2]], [[3, 4], [5]], [[6]]])
    >>> dp1 = source_dp.unbatch()
    >>> list(dp1)
    [[0, 1], [2], [3, 4], [5], [6]]
    >>> dp2 = source_dp.unbatch(unbatch_level=2)
    >>> list(dp2)
    [0, 1, 2, 3, 4, 5, 6]
c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )r   r#   Úunbatch_levelr   N)r   r'   )r   r*   s   "€r   r   Ú"UnBatcherIterDataPipe.__annotate__r   s"   ø€ ÷ +ñ +¡ð +¹cð +È$ñ +r   c                ó   € Wn         W n        R # ©N©r#   rP   )r0   r#   rP   s   &&&r   r/   ÚUnBatcherIterDataPipe.__init__r   s   € Ø ŒØ*Ör   c              #  ó€   "  € V P                    F'  pV P                  WP                  R 7       Rj  x€L
  K)  	  R#  L
5i)©rP   N)r#   Ú_diverP   )r0   Úelements   & r   r:   ÚUnBatcherIterDataPipe.__iter__v   s0   é € Ø—}”}ˆGØ—z‘z '×9KÑ9K�zÓL×LÒLó %ÙLùs   ‚/>±<²>c              #  ó°  "  € VR8  d   \        R4      hVR8X  dI   \        V\        \        34      '       d'   V F  pV P	                  VRR7       Rj  x€L
  K   	  R# Vx € R# V^ 8X  d   Vx € R# \        V\        \        34      '       d-   V F$  pV P	                  W2^,
          R7       Rj  x€L
  K&  	  R# \        RV P                   R24      h L~ L%5i)r>   z unbatch_level must be -1 or >= 0rW   Nzunbatch_level z" exceeds the depth of the DataPipeéÿÿÿÿ)Ú
ValueErrorr?   Úlistr   rX   Ú
IndexErrorrP   )r0   rY   rP   Úitems   &&& r   rX   ÚUnBatcherIterDataPipe._divez   sË   é € Ø˜2ÔÜÐ?Ó@Ð@Ø˜BÔÜ˜'¤D¬)Ð#4×5Ò5Û#�DØ#Ÿz™z¨$¸b˜zÓA×AÒAó $ð ”Ø˜aÔØŒMä˜'¤D¬)Ð#4×5Ò5Û#�DØ#Ÿz™z¨$ÈaÕ>O˜zÓP×PÒPó $ô !Ø$ T×%7Ñ%7Ð$8Ð8ZÐ[óð ñ Bñ Qùs%   ‚ACÁCÁACÂ.CÂ/$CÃCrT   N)r>   )
r   rE   rF   rG   rH   r/   r:   rX   rJ   rK   ©r*   s   @r   r   r   Z   s$   ø‡ € ñ÷,+ò +òM÷ð r   Úgroupbyc            
       óŠ   a € ] tR t^�t o RtRRRRRRRRR	R/V 3R
 lR lltR tR tV 3R lR ltR t	R t
V 3R lR ltRtV tR# )r   aÞ	  
Groups data from IterDataPipe by keys from ``group_key_fn``, yielding a ``DataChunk`` with batch size up to ``group_size``.

(functional name: ``groupby``).

The samples are read sequentially from the source ``datapipe``, and a batch of samples belonging to the same group
will be yielded as soon as the size of the batch reaches ``group_size``. When the buffer is full,
the DataPipe will yield the largest batch with the same key, provided that its size is larger
than ``guaranteed_group_size``. If its size is smaller, it will be dropped if ``drop_remaining=True``.

After iterating through the entirety of source ``datapipe``, everything not dropped due to the buffer capacity
will be yielded from the buffer, even if the group sizes are smaller than ``guaranteed_group_size``.

Args:
    datapipe: Iterable datapipe to be grouped
    group_key_fn: Function used to generate group key from the data of the source datapipe
    keep_key: Option to yield the matching key along with the items in a tuple,
        resulting in `(key, [items])` otherwise returning [items]
    buffer_size: The size of buffer for ungrouped data
    group_size: The max size of each group, a batch is yielded as soon as it reaches this size
    guaranteed_group_size: The guaranteed minimum group size to be yielded in case the buffer is full
    drop_remaining: Specifies if the group smaller than ``guaranteed_group_size`` will be dropped from buffer
        when the buffer is full

Example:
    >>> import os
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import IterableWrapper
    >>> def group_fn(file):
    ...     return os.path.basename(file).split(".")[0]
    >>> source_dp = IterableWrapper(
    ...     ["a.png", "b.png", "a.json", "b.json", "a.jpg", "c.json"]
    ... )
    >>> dp0 = source_dp.groupby(group_key_fn=group_fn)
    >>> list(dp0)
    [['a.png', 'a.json', 'a.jpg'], ['b.png', 'b.json'], ['c.json']]
    >>> # A group is yielded as soon as its size equals to `group_size`
    >>> dp1 = source_dp.groupby(group_key_fn=group_fn, group_size=2)
    >>> list(dp1)
    [['a.png', 'a.json'], ['b.png', 'b.json'], ['a.jpg'], ['c.json']]
    >>> # Scenario where `buffer` is full, and group 'a' needs to be yielded since its size > `guaranteed_group_size`
    >>> dp2 = source_dp.groupby(
    ...     group_key_fn=group_fn,
    ...     buffer_size=3,
    ...     group_size=3,
    ...     guaranteed_group_size=2,
    ... )
    >>> list(dp2)
    [['a.png', 'a.json'], ['b.png', 'b.json'], ['a.jpg'], ['c.json']]
Úkeep_keyFÚbuffer_sizei'  Ú
group_sizeNÚguaranteed_group_sizeÚdrop_remainingc                óŒ   <€ V ^8„  d   QhRS[ S[,          RS[S[.S[3,          RS[RS[RS[R,          RS[R,          RS[R	R/# )
r   r#   Úgroup_key_fnre   rf   rg   Nrh   ri   r   )r   r   r   r   r(   r'   )r   r*   s   "€r   r   Ú GrouperIterDataPipe.__annotate__Ä   ss   ø€ ÷ "'ñ "'á™uÕ%ð"'ñ ¡˜w©˜|Õ,ð"'ñ
 ð"'ñ ð"'ñ ˜$•Jð"'ñ  # T�zð"'ñ ð"'ð 
ñ"'r   c               óf  € \        V4       Wn        W n        W0n        W@n        \        \        4      V n        ^ V n        WPn	        RV n
        Ve'   Ve#   ^ Tu;8  d   V8:  g   M \        R4      hWPn
        Ve'   Ve   ^ Tu;8  d   V8:  g   M \        R4      hW`n
        Wpn        \        V n        R# )r   Nz)group_size must be > 0 and <= buffer_sizezNguaranteed_group_size must be > 0 and <= group_size and group_size must be set)r   r#   rk   re   Úmax_buffer_sizer   r^   Úbuffer_elementsÚcurr_buffer_sizerg   rh   r-   ri   r   r&   )r0   r#   rk   re   rf   rg   rh   ri   s   &&&$$$$$r   r/   ÚGrouperIterDataPipe.__init__Ä   s­   € ô 	˜\Ô*à Œà(Ôà ŒØ*ÔÜ7BÄ4Ó7HˆÔØ !ˆÔØ$ŒØ%)ˆÔ"ØÒ! kÒ&=Ø˜
Ö1 kÖ1Ü$Ð%PÓQÐQØ)3Ô&Ø Ò,ØÒ!¨!Ð.CÖ*QÀzÖ*QÜ$Ødóð ð *?Ô&Ø,ÔÜ&ˆÖr   c                ó  € R p^ pR pV P                    FD  p\        V P                   V,          4      V8”  g   K&  \        V P                   V,          4      pTpKF  	  V P                  eI   W P                  8  d9   V P                  '       g'   \	        R\        V P                   V,          4      4      hV P                  e   W P                  8¼  d   V P                   V,          pV ;P                  V,          un        V P                   V V# )NzFailed to group items)ro   r8   rh   ri   ÚRuntimeErrorr   rp   )r0   Úbiggest_keyÚbiggest_sizeÚresult_to_yieldÚfindkeys   &    r   Ú_remove_biggest_keyÚ'GrouperIterDataPipe._remove_biggest_keyè   sê   € ØˆØˆØˆØ×+Ô+ˆGÜ�4×'Ñ'¨Õ0Ó1°LÖ@Ü" 4×#7Ñ#7¸Õ#@ÓA�Ø%’ñ ,ð ×&Ñ&Ò2Ø×9Ñ9Ô9Ø×'×'Ð'äØ'¬¨T×-AÑ-AÀ+Õ-NÓ)Oóð ð
 ×&Ñ&Ò.Ø×9Ñ9Ô9à"×2Ñ2°;Õ?ˆOà×Ò Õ-ÕØ× Ñ  Ð-àÐr   c              #  ó  "  € V P                    EFc  pV P                  V4      pV P                  V,          P                  V4       V ;P                  ^,          un        V P
                  e§   V P
                  \        V P                  V,          4      8X  d|   V P                  V P                  V,          4      pV P                  '       d   W#3MTx € V ;P                  \        V P                  V,          4      ,          un        V P                  V V P                  V P                  8X  g   EK"  V P                  4       pVf   EK9  V P                  V4      pV P                  '       d   W#3MTx € EKf  	  \        V P                  P                  4       4       Fh  pV P                  V P                  P                  V4      4      pV ;P                  \        V4      ,          un        V P                  '       d   W#3MTx € Kj  	  R# 5i)r>   N)r#   rk   ro   r7   rp   rg   r8   r&   re   rn   rx   ÚtupleÚkeysÚpop)r0   r9   ÚkeyÚresultrv   s   &    r   r:   ÚGrouperIterDataPipe.__iter__  s‰  é € Ø—•ˆAØ×#Ñ# AÓ&ˆCà× Ñ  Õ%×,Ñ,¨QÔ/Ø×!Ò! QÕ&Õ!à�‰Ò*¨t¯©Ä#Ø×$Ñ$ SÕ)óCô 0ð *.×);Ñ);¸D×<PÑ<PÐQTÕ<UÓ)V�Ø'+§}§} }�s‘m¸&Ò@Ø×%Ò%¬¨T×-AÑ-AÀ#Õ-FÓ)GÕGÕ%Ø×(Ñ(¨Ð-à×$Ñ$¨×(<Ñ(<×<Ø"&×":Ñ":Ó"<�Ø"Õ.Ø!×/Ñ/°Ó@�FØ+/¯=¯=¨=˜3™-¸fÕDñ% ô( ˜×-Ñ-×2Ñ2Ó4Ö5ˆCØ×'Ñ'¨×(<Ñ(<×(@Ñ(@ÀÓ(EÓFˆFØ×!Ò!¤S¨£[Õ0Õ!Ø#'§=§= =�3‘-°fÔ<ó 6ùs    ‚C	HÃAHÄ1HÅ"HÅ+BHc                ó   <€ V ^8„  d   QhRR/# ©r   r   N© )r   r*   s   "€r   r   rl     s   ø€ ÷ 1ñ 1�tñ 1r   c                ó<   € ^ V n         \        \        4      V n        R# r6   )rp   r   r^   ro   rA   s   &r   ÚresetÚGrouperIterDataPipe.reset  s   € Ø !ˆÔÜ*¬4Ó0ˆÖr   c           
     ó6  € V P                   V P                  V P                  V P                  V P                  V P
                  V P                  V P                  V P                  V P                  3
p\        P                  e   \        P                  ! V4      # V# rS   )r#   rk   re   rn   rg   rh   ri   r&   Ú_valid_iterator_idÚ_number_of_samples_yieldedr   Úgetstate_hook©r0   Ústates   & r   Ú__getstate__Ú GrouperIterDataPipe.__getstate__#  s�   € à�M‰MØ×ÑØ�M‰MØ× Ñ Ø�O‰OØ×&Ñ&Ø×ÑØ×ÑØ×#Ñ#Ø×+Ñ+ð
ˆô ×%Ñ%Ò1Ü×-Ò-¨eÓ4Ð4Øˆr   c                óº   € Vw
  V n         V n        V n        V n        V n        V n        V n        V n        V n        V n	        ^ V n
        \        \        4      V n        R# r6   )r#   rk   re   rn   rg   rh   ri   r&   rˆ   r‰   rp   r   r^   ro   r‹   s   &&r   Ú__setstate__Ú GrouperIterDataPipe.__setstate__4  sZ   € ð ñ	
ØŒMØÔØŒMØÔ ØŒOØÔ&ØÔØÔØÔ#ØÔ+à !ˆÔÜ*¬4Ó0ˆÖr   c                ó   <€ V ^8„  d   QhRR/# r‚   rƒ   )r   r*   s   "€r   r   rl   D  s   ø€ ÷ %ñ %˜ñ %r   c                ó:   € V P                   P                  4        R # rS   )ro   ÚclearrA   s   &r   Ú__del__ÚGrouperIterDataPipe.__del__D  s   € Ø×Ñ×"Ñ"Ö$r   )r‰   rˆ   ro   rp   r#   ri   rk   rg   rh   re   rn   r&   )r   rE   rF   rG   rH   r/   rx   r:   r…   r�   r�   r•   rJ   rK   rb   s   @r   r   r   �   sp   ø‡ € ñ1ðf"'ð
 ð"'ð !ð"'ð "&ð"'ð -1ð"'ð  %÷"'ò "'òHò:=÷41ð 1òò"1÷ %ö %r   N)r   r   r   )Úcollectionsr   Úcollections.abcr   r   r   Útypingr   r   r	   Ú%torch.utils.data.datapipes._decoratorr
   Ú#torch.utils.data.datapipes.datapiper   r   Ú'torch.utils.data.datapipes.utils.commonr   Ú__all__r   r   r   r   r   rƒ   r   r   Ú<module>rž      sª   ðå #ß 5Ñ 5ß )Ñ )å Eß GÝ Hò€ñ 	� 4Ô(€õGñ �WÓô=Y˜, yÕ1ó =Yó ð=Yñ@ �YÓô1˜Ló 1ó  ð1ñh �YÓôu%˜, yÕ1ó u%ó  òu%r   