
    ΅i=                     r    S SK r S SKrS SKJrJrJr  S SKJr  S SKJ	r	  \" S5      r
S/r " S S\	\
   5      rg)    N)IterableIteratorSized)TypeVar)IterDataPipe_TIterableWrapperIterDataPipec                   Z    \ rS rSrSrSS\\   S\SS4S jjrS\	\   4S jr
S\4S	 jrS
rg)r	      a  
Wraps an iterable object to create an IterDataPipe.

Args:
    iterable: Iterable object to be wrapped into an IterDataPipe
    deepcopy: Option to deepcopy input iterable object for each
        iterator. The copy is made when the first element is read in ``iter()``.

.. note::
    If ``deepcopy`` is explicitly set to ``False``, users should ensure
    that the data pipeline doesn't contain any in-place operations over
    the iterable instance to prevent data inconsistency across iterations.

Example:
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import IterableWrapper
    >>> dp = IterableWrapper(range(10))
    >>> list(dp)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
iterabledeepcopyreturnNc                     Xl         X l        g )N)r   r   )selfr   r   s      _/home/james-whalen/.local/lib/python3.13/site-packages/torch/utils/data/datapipes/iter/utils.py__init__$IterableWrapperIterDataPipe.__init__$   s          c              #      #    U R                   nU R                  (       a!   [        R                  " U R                   5      nU S h  vN   g ! [         a    [        R
                  " SSS9   N,f = f N*7f)NzlThe input iterable can not be deepcopied, please be aware of in-place modification would affect source data.   )
stacklevel)r   r   copy	TypeErrorwarningswarn)r   source_datas     r   __iter__$IterableWrapperIterDataPipe.__iter__(   sb     mm=="mmDMM:   Y  	s4   A3 A A3A1A3A.+A3-A..A3c                     [        U R                  [        5      (       a  [        U R                  5      $ [	        [        U 5      R                   S35      e)Nz# instance doesn't have valid length)
isinstancer   r   lenr   type__name__)r   s    r   __len__#IterableWrapperIterDataPipe.__len__9   s@    dmmU++t}}%%4:..//RSTTr   )r   r   )T)r#   
__module____qualname____firstlineno____doc__r   r   boolr   r   r   intr$   __static_attributes__ r   r   r	   r	      sC    *!" ! ! !(2, "U Ur   )r   r   collections.abcr   r   r   typingr   #torch.utils.data.datapipes.datapiper   r   __all__r	   r-   r   r   <module>r2      s=      5 5  < T](
).U,r"2 .Ur   