
    QVjis              	           d dl mZ d dlmZ d dlmZ d dlmZ ddgZ edd	          Z	 ed
           G d de                      Z
 ed           G d deee	df                                        ZdS )    )Sized)TypeVar)functional_datapipe)MapDataPipeConcaterMapDataPipeZipperMapDataPipe_T_coT)	covariantconcatc                   N    e Zd ZU dZee         ed<   defdZdefdZ	de
fdZdS )r   a  
    Concatenate multiple Map DataPipes (functional name: ``concat``).

    The new index of is the cumulative sum of source DataPipes.
    For example, if there are 2 source DataPipes both with length 5,
    index 0 to 4 of the resulting `ConcatMapDataPipe` would refer to
    elements of the first DataPipe, and 5 to 9 would refer to elements
    of the second DataPipe.

    Args:
        datapipes: Map DataPipes being concatenated

    Example:
        >>> # xdoctest: +SKIP
        >>> from torchdata.datapipes.map import SequenceWrapper
        >>> dp1 = SequenceWrapper(range(3))
        >>> dp2 = SequenceWrapper(range(3))
        >>> concat_dp = dp1.concat(dp2)
        >>> list(concat_dp)
        [0, 1, 2, 0, 1, 2]
    	datapipesc                     t          |          dk    rt          d          t          d |D                       st          d          t          d |D                       st          d          || _        d S )Nr   /Expected at least one DataPipe, but got nothingc              3   @   K   | ]}t          |t                    V  d S N
isinstancer   .0dps     b/root/voice-cloning/.venv/lib/python3.11/site-packages/torch/utils/data/datapipes/map/combining.py	<genexpr>z/ConcaterMapDataPipe.__init__.<locals>.<genexpr>+   ,      CC2:b+..CCCCCC    'Expected all inputs to be `MapDataPipe`c              3   @   K   | ]}t          |t                    V  d S r   r   r   r   s     r   r   z/ConcaterMapDataPipe.__init__.<locals>.<genexpr>-   ,      ==R:b%((======r   !Expected all inputs to be `Sized`len
ValueErrorall	TypeErrorr   selfr   s     r   __init__zConcaterMapDataPipe.__init__(       y>>QNOOOCCCCCCC 	GEFFF==9===== 	A?@@@"r   returnc                     d}| j         D ]7}||z
  t          |          k     r|||z
           c S |t          |          z  }8t          d| d          )Nr   Index z is out of range.)r   r!   
IndexError)r&   indexoffsetr   s       r   __getitem__zConcaterMapDataPipe.__getitem__1   sn    . 	" 	"Bv~B''%&.))))#b''!:%:::;;;r   c                 >    t          d | j        D                       S )Nc              3   4   K   | ]}t          |          V  d S r   r!   r   s     r   r   z.ConcaterMapDataPipe.__len__.<locals>.<genexpr>;   (      44r3r77444444r   )sumr   r&   s    r   __len__zConcaterMapDataPipe.__len__:   !    44T^444444r   N)__name__
__module____qualname____doc__tupler   __annotations__r'   r	   r/   intr6    r   r   r   r      s          , [!!!!#; # # # #<E < < < <5 5 5 5 5 5 5r   zipc                   ~    e Zd ZU dZeee         df         ed<   dee         ddfdZdeedf         fdZ	de
fdZdS )	r   a%  
    Aggregates elements into a tuple from each of the input DataPipes (functional name: ``zip``).

    This MataPipe is out of bound as soon as the shortest input DataPipe is exhausted.

    Args:
        *datapipes: Map DataPipes being aggregated

    Example:
        >>> # xdoctest: +SKIP
        >>> from torchdata.datapipes.map import SequenceWrapper
        >>> dp1 = SequenceWrapper(range(3))
        >>> dp2 = SequenceWrapper(range(10, 13))
        >>> zip_dp = dp1.zip(dp2)
        >>> list(zip_dp)
        [(0, 10), (1, 11), (2, 12)]
    .r   r)   Nc                     t          |          dk    rt          d          t          d |D                       st          d          t          d |D                       st          d          || _        d S )Nr   r   c              3   @   K   | ]}t          |t                    V  d S r   r   r   s     r   r   z-ZipperMapDataPipe.__init__.<locals>.<genexpr>W   r   r   r   c              3   @   K   | ]}t          |t                    V  d S r   r   r   s     r   r   z-ZipperMapDataPipe.__init__.<locals>.<genexpr>Y   r   r   r   r    r%   s     r   r'   zZipperMapDataPipe.__init__T   r(   r   c           	          g }| j         D ]G}	 |                    ||                    # t          $ r}t          d| d| d          |d }~ww xY wt          |          S )Nr+   z3 is out of range for one of the input MapDataPipes .)r   appendr,   r<   )r&   r-   resr   es        r   r/   zZipperMapDataPipe.__getitem__]   s    . 	 	B

2e9%%%%    \U\\WY\\\  Szzs   )
AA

Ac                 >    t          d | j        D                       S )Nc              3   4   K   | ]}t          |          V  d S r   r2   r   s     r   r   z,ZipperMapDataPipe.__len__.<locals>.<genexpr>i   r3   r   )minr   r5   s    r   r6   zZipperMapDataPipe.__len__h   r7   r   )r8   r9   r:   r;   r<   r   r	   r=   r'   r/   r>   r6   r?   r   r   r   r   >   s          $ [',----#;u#5 #$ # # # #	E%*$5 	 	 	 	5 5 5 5 5 5 5r   .N)collections.abcr   typingr   %torch.utils.data.datapipes._decoratorr   #torch.utils.data.datapipes.datapiper   __all__r	   r   r<   r   r?   r   r   <module>rR      s   ! ! ! ! ! !       E E E E E E ; ; ; ; ; ; !"5
64((( X,5 ,5 ,5 ,5 ,5+ ,5 ,5 ,5^ U*5 *5 *5 *5 *5E%*$56 *5 *5 *5 *5 *5r   