+
    ˜°³jš#  ã                   ó  € ^ RI t ^ RIHt ^ RIHtHtHt ^ RIHtH	t	 ^ RI
t
^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHtHt R
R.t]	! RRR7      t]! R4       ! R R]],          4      4       tR t]! R4       ! R R
]4      4       tR# )é    N)Ú
namedtuple)ÚCallableÚIteratorÚSized)ÚAnyÚTypeVar)Údefault_collate)Úfunctional_datapipe)Údataframe_wrapper)ÚIterDataPipe)Ú_check_unpickable_fnÚvalidate_input_colÚCollatorIterDataPipeÚMapperIterDataPipeÚ_T_coT)Ú	covariantÚmapc                   ó|   a a€ ] tR t^t oRtRV3R lV 3R llltR 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   ao  
Applies a function over each item from the source DataPipe (functional name: ``map``).

The function can be any regular Python function or partial object. Lambda
function is not recommended as it is not supported by pickle.

Args:
    datapipe: Source Iterable DataPipe
    fn: Function being applied over each item
    input_col: Index or indices of data which ``fn`` is applied, such as:

        - ``None`` as default to apply ``fn`` to the data directly.
        - Integer(s) is used for list/tuple.
        - Key(s) is used for dict.

    output_col: Index of data where result of ``fn`` is placed. ``output_col`` can be specified
        only when ``input_col`` is not ``None``

        - ``None`` as default to replace the index that ``input_col`` specified; For ``input_col`` with
          multiple indices, the left-most one is used, and other indices will be removed.
        - Integer is used for list/tuple. ``-1`` represents to append result at the end.
        - Key is used for dict. New key is acceptable.

Example:
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import IterableWrapper, Mapper
    >>> def add_one(x):
    ...     return x + 1
    >>> dp = IterableWrapper(range(10))
    >>> # Invocation via functional form is preferred
    ... map_dp_1 = dp.map(add_one)
    >>> list(map_dp_1)
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    >>> # We discourage the usage of `lambda` functions as they are not serializable with `pickle`
    >>> # Use `functools.partial` or explicitly define the function instead
    >>> map_dp_2 = Mapper(dp, lambda x: x + 1)
    >>> list(map_dp_2)
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )é   ÚdatapipeÚfnÚreturnN©r   r   )ÚformatÚ__classdict__s   "€Úi/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/utils/data/datapipes/iter/callable.pyÚ__annotate__ÚMapperIterDataPipe.__annotate__H   s)   ø€ ÷ *ñ *áð*ñ ð*ð 
ñ*ó    c                ód  <€ \         P                  P                  R 4       \        SV `  4        Wn        \        V4       W n        W0n        Vf   Ve   \        R4      h\        V\        \        34      '       d%   \        V4      ^8”  d   \        R4      hV^ ,          pW@n        \        W#4       R# )zpython.data_pipes.mapNz3`output_col` must be None when `input_col` is None.z3`output_col` must be a single-element list or tuple)ÚtorchÚ_CÚ_log_api_usage_onceÚsuperÚ__init__r   r   r   Ú	input_colÚ
ValueErrorÚ
isinstanceÚlistÚtupleÚlenÚ
output_colr   )Úselfr   r   r'   r-   Ú	__class__s   &&&&&€r   r&   ÚMapperIterDataPipe.__init__H   s�   ø€ ô 	�‰×$Ñ$Ð%<Ô=Ü‰ÑÔØ Œä˜RÔ ØŒà"ŒØÒ Ò!7ÜÐRÓSÐSÜ�j¤4¬ -×0Ò0Ü�:‹ Ô"Ü Ð!VÓWÐWØ# A�ˆJØ$ŒÜ˜2Ö)r    c                ó¼  a€ V P                   f    V P                  f   V P                  S4      # V P                   f   V P                  S4      pMŸ\        V P                   \        \
        34      '       dX   \
        ;QJ d!    . V3R lV P                    4       F  NK  	  5M! V3R lV P                    4       4      pV P                  ! V!  pM"V P                  SV P                   ,          4      p\        S\
        4      '       d   Rp\	        S4      oMRpV P                  fv   \        V P                   \        \
        34      '       d@   VSV P                   ^ ,          &   \        V P                   R,          RR7       F  pSV K  	  MBVSV P                   &   M2V P                  R8X  d   SP                  V4       MVSV P                  &   V'       d   \        S4      # S# )Nc              3   ó6   <"  € T F  pSV,          x € K  	  R # 5i©N© )Ú.0ÚcolÚdatas   & €r   Ú	<genexpr>Ú/MapperIterDataPipe._apply_fn.<locals>.<genexpr>g   s   øé € Ð=©n s˜˜cŸš«nùs   ƒTF:é   NN)Úreverseéÿÿÿÿ)r'   r-   r   r)   r*   r+   ÚsortedÚappend)r.   r7   ÚresÚargsÚt_flagÚidxs   &f    r   Ú	_apply_fnÚMapperIterDataPipe._apply_fn`   sY  ø€ Ø�>‰>Ò! d§o¡oÒ&=Ø—7‘7˜4“=Ð à�>‰>Ò!Ø—'‘'˜$“-‰CÜ˜Ÿ™¬¬u¨×6Ò6ß”5Ô=¨d¯nªnÓ=—5‘5Ô=¨d¯nªnÓ=Ó=ˆDØ—'’'˜4‘.‰Cà—'‘'˜$˜tŸ~™~Õ.Ó/ˆCô �dœE×"Ò"ØˆFÜ˜“:‰DàˆFà�?‰?Ò"Ü˜$Ÿ.™.¬4´¨-×8Ò8Ø*-��T—^‘^ AÕ&Ñ'Ü! $§.¡.°Õ"4¸d×C�CØ˜Sš	ò Dð (+��T—^‘^Ò$à�‰ "Ô$Ø—‘˜CÕ à(+��T—_‘_Ñ%÷ %Œu�T‹{Ð.¨$Ð.r    c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r   r   )r   r   )r   r   s   "€r   r   r   ƒ   s   ø€ ÷ 'ñ '™(¡5�/ñ 'r    c              #  óZ   "  € V P                    F  pV P                  V4      x € K  	  R # 5ir3   )r   rC   )r.   r7   s   & r   Ú__iter__ÚMapperIterDataPipe.__iter__ƒ   s"   é € Ø—M”MˆDØ—.‘. Ó&Ô&ó "ùs   ‚)+c                ó    <€ V ^8„  d   QhRS[ /# rF   )Úint)r   r   s   "€r   r   r   ‡   s   ø€ ÷ Uñ U™ñ Ur    c                ó®   € \        V P                  \        4      '       d   \        V P                  4      # \	        \        V 4      P                   R 24      h)z# instance doesn't have valid length)r)   r   r   r,   Ú	TypeErrorÚtypeÚ__name__)r.   s   &r   Ú__len__ÚMapperIterDataPipe.__len__‡   s@   € ä�d—m‘m¤U×+Ò+Ü�t—}‘}Ó%Ð%Üœ4 ›:×.Ñ.Ð/Ð/RÐSÓTÐTr    c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   # )r   r   r   r   )r   r   s   "€r   r   r      s"   ø‡ ‚ ñT ÑñU ñV 	�LòW r    )r   r   r'   r-   )NN)rO   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r&   rC   rH   rP   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r/   r   s   @@r   r   r      s9   ù‡ € ñ&÷V*õ *ò0!/÷F'ð '÷Uð U÷Y … r    c                 óT  € \        VP                  4      ^8”  d   \        R4      hV^ ,          p\        P                  ! V4      p. p. pV  F  pWc9  g   K  \        R4      h	  V FŽ  pW`9   d,   \        W,          4      '       g   \        R4      hW,          pM! ^ RIHp VP                  P                  4       pVP                  \        V4      4       V! W&,          4      p
VP                  V
4       K�  	  \        RV4      pV! V!  pV#   \         d   p	\        R4      T	hRp	?	ii ; i)r:   z%Only supports one DataFrame per batchzConversion keys mismatchz5Collate (DF)DataPipe requires callable as dict valuesNz?unable to import default collation function from the TorchArrowÚCollateResult)r,   ÚitemsÚRuntimeErrorÚ
df_wrapperÚget_columnsÚcallableÚtorcharrow.pytorchÚpytorchÚrecÚDefaultÚ	Exceptionr>   Ústrr   )Ú
conversionÚitemÚdfÚcolumns_nameÚtuple_namesÚtuple_valuesÚnameÚcollation_fnÚtapÚeÚvalueÚtpl_clsr+   s   &&           r   Ú_collate_helperru   Ž   s  € ä
ˆ4�:‰:ƒ˜ÔäÐBÓCÐCØ	ˆa�€BÜ×)Ò)¨"Ó-€LØ€KØ€LãˆØÖ#ÜÐ9Ó:Ð:ñ ó ˆØÔÜ˜JÕ,×-Ò-Ü"ØKóð ð &Õ+‰LðÝ0à"Ÿw™wŸ™Ó0�ð 	×Ñœ3˜t›9Ô%Ù˜R�XÓ&ˆØ×Ñ˜EÖ"ñ) ô0 ˜¨+Ó6€GÙ�\Ñ"€EØ€Løô ô Ü"ØUóàðûðús   Â DÄD'ÄD"Ä"D'Úcollatec                   óJ   a a€ ] tR t^¹t oRt]R3V3R lV 3R llltRtVtV ;t	# )r   aÅ  
Collates samples from DataPipe to Tensor(s) by a custom collate function (functional name: ``collate``).

By default, it uses :func:`torch.utils.data.default_collate`.

.. note::
    While writing a custom collate function, you can import :func:`torch.utils.data.default_collate` for the
    default behavior and `functools.partial` to specify any additional arguments.

Args:
    datapipe: Iterable DataPipe being collated
    collate_fn: Customized collate function to collect and combine data or a batch of data.
        Default function collates to Tensor(s) based on data type.

Example:
    >>> # xdoctest: +SKIP
    >>> # Convert integer data to float Tensor
    >>> class MyIterDataPipe(torch.utils.data.IterDataPipe):
    ...     def __init__(self, start, end):
    ...         super(MyIterDataPipe).__init__()
    ...         assert end > start, "this example only works with end >= start"
    ...         self.start = start
    ...         self.end = end
    ...
    ...     def __iter__(self):
    ...         return iter(range(self.start, self.end))
    ...
    ...     def __len__(self):
    ...         return self.end - self.start
    >>> ds = MyIterDataPipe(start=3, end=7)
    >>> print(list(ds))
    [3, 4, 5, 6]
    >>> def collate_fn(batch):
    ...     return torch.tensor(batch, dtype=torch.float)
    >>> collated_ds = CollateIterDataPipe(ds, collate_fn=collate_fn)
    >>> print(list(collated_ds))
    [tensor(3.), tensor(4.), tensor(5.), tensor(6.)]
Nc                ó¦   <€ V ^8„  d   QhRS[ RS[RS[3,          S[S[S[,          S[S[,          3,          ,          R,          RS[R,          RR/# )r   r   ri   .NÚ
collate_fnr   )r   r   r   Údictrh   )r   r   s   "€r   r   Ú!CollatorIterDataPipe.__annotate__â   sb   ø€ ÷ :ñ :áð:ñ ˜S¡#˜XÕ&Ù
‰s‘S�y™(¡S�.Ð(Õ
)õ*à
õð:ñ ˜t•Oð:ð 
ñ:r    c                óÐ   <€ Ve   \         SV `  WR7       R # \        V4      '       d   \         SV `  WR7       R # \        P                  ! \
        V4      p\         SV `  WR7       R # )N)r   )r%   r&   rb   Ú	functoolsÚpartialru   )r.   r   ri   ry   r/   s   &&&&€r   r&   ÚCollatorIterDataPipe.__init__â   sZ   ø€ ð Ò!Ü‰GÑ˜XÐÖ5ä˜
×#Ò#Ü‘Ñ  Ð Ö9ô '×.Ò.¬À
ÓK�
Ü‘Ñ  Ð Ö9r    r4   )
rO   rS   rT   rU   rV   r	   r&   rX   rY   rZ   r[   s   @@r   r   r   ¹   s"   ù‡ € ñ%ðX !Ø&*÷:÷ :õ :r    )r}   Úcollectionsr   Úcollections.abcr   r   r   Útypingr   r   r"   Útorch.utils.data._utils.collater	   Ú%torch.utils.data.datapipes._decoratorr
   Ú$torch.utils.data.datapipes.dataframer   r`   Ú#torch.utils.data.datapipes.datapiper   Ú'torch.utils.data.datapipes.utils.commonr   r   Ú__all__r   r   ru   r   r4   r    r   Ú<module>r‰      s˜   ðã Ý "ß 5Ñ 5ß ã Ý ;Ý EÝ PÝ <÷ð Øð€ñ 	� 4Ô(€ñ �UÓôoU˜ eÕ,ó oUó ðoUòd(ñV �YÓô::Ð-ó ::ó  ò::r    