o
    wZh                     @   s6   d dl Z d dlZd dlmZ dgZG dd deZdS )    N)IterDataPipeIterableWrapperIterDataPipec                   @   s*   e Zd ZdZd
ddZdd Zdd Zd	S )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]
    Tc                 C   s   || _ || _d S N)iterabledeepcopy)selfr   r    r   T/var/www/auris/lib/python3.10/site-packages/torch/utils/data/datapipes/iter/utils.py__init__!   s   
z$IterableWrapperIterDataPipe.__init__c                 c   sJ    | j }| jrzt| j }W n ty   td Y nw |E d H  d S )NzlThe input iterable can not be deepcopied, please be aware of in-place modification would affect source data.)r   r   copy	TypeErrorwarningswarn)r   Zsource_datar   r   r	   __iter__%   s   z$IterableWrapperIterDataPipe.__iter__c                 C   s
   t | jS r   )lenr   )r   r   r   r	   __len__5   s   
z#IterableWrapperIterDataPipe.__len__N)T)__name__
__module____qualname____doc__r
   r   r   r   r   r   r	   r      s
    
)r   r   Z#torch.utils.data.datapipes.datapiper   __all__r   r   r   r   r	   <module>   s
   