o
    ôj™  ã                   @   sv   d dl Z d dlmZ d dlmZmZmZmZmZm	Z	 d dl
m  mZ ddlmZ G dd„ dejƒZG dd	„ d	ƒZdS )
é    N)ÚPath)ÚAnyÚCallableÚListÚOptionalÚTupleÚUnioné   )Ú_log_api_usage_oncec                   @   s¦   e Zd ZdZdZ				ddeeef dee	 dee	 dee	 ddf
d	d
„Z
dedefdd„Zdefdd„Zdefdd„Zde	dedee fdd„Zdefdd„ZdS )ÚVisionDatasetaB  
    Base Class For making datasets which are compatible with torchvision.
    It is necessary to override the ``__getitem__`` and ``__len__`` method.

    Args:
        root (string, optional): Root directory of dataset. Only used for `__repr__`.
        transforms (callable, optional): A function/transforms that takes in
            an image and a label and returns the transformed versions of both.
        transform (callable, optional): A function/transform that takes in a PIL image
            and returns a transformed version. E.g, ``transforms.RandomCrop``
        target_transform (callable, optional): A function/transform that takes in the
            target and transforms it.

    .. note::

        :attr:`transforms` and the combination of :attr:`transform` and :attr:`target_transform` are mutually exclusive.
    é   NÚrootÚ
transformsÚ	transformÚtarget_transformÚreturnc                 C   sp   t | ƒ t|tƒrtj |¡}|| _|d u}|d up|d u}|r&|r&tdƒ‚|| _|| _	|r3t
||ƒ}|| _d S )NzGOnly transforms or transform/target_transform can be passed as argument)r
   Ú
isinstanceÚstrÚosÚpathÚ
expanduserr   Ú
ValueErrorr   r   ÚStandardTransformr   )Úselfr   r   r   r   Zhas_transformsZhas_separate_transform© r   úl/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/torchvision/datasets/vision.pyÚ__init__   s   


zVisionDataset.__init__Úindexc                 C   ó   t ‚)z¦
        Args:
            index (int): Index

        Returns:
            (Any): Sample and meta data, optionally transformed by the respective transforms.
        ©ÚNotImplementedError)r   r   r   r   r   Ú__getitem__8   s   zVisionDataset.__getitem__c                 C   r   ©Nr   ©r   r   r   r   Ú__len__B   ó   zVisionDataset.__len__c                    sŽ   dˆ j j }dˆ  ¡ › �g}ˆ jd ur| dˆ j› �¡ |ˆ  ¡  ¡ 7 }tˆ dƒr6ˆ jd ur6|t	ˆ jƒg7 }|g‡ fdd„|D ƒ }d 
|¡S )NzDataset zNumber of datapoints: zRoot location: r   c                    s   g | ]	}d ˆ j  | ‘qS )ú )Ú_repr_indent©Ú.0Úliner#   r   r   Ú
<listcomp>M   s    z*VisionDataset.__repr__.<locals>.<listcomp>Ú
)Ú	__class__Ú__name__r$   r   ÚappendÚ
extra_reprÚ
splitlinesÚhasattrr   ÚreprÚjoin)r   ÚheadÚbodyÚlinesr   r#   r   Ú__repr__E   s   

zVisionDataset.__repr__r5   c                    ó8   |  ¡  ¡ }ˆ › |d › �g‡ fdd„|dd … D ƒ S )Nr   c                    ó    g | ]}d   dtˆ ƒ |¡‘qS ©z{}{}r&   ©ÚformatÚlenr(   ©r5   r   r   r+   R   ó     z8VisionDataset._format_transform_repr.<locals>.<listcomp>é   ©r8   r1   ©r   r   r5   r7   r   r?   r   Ú_format_transform_reprP   ó   ,z$VisionDataset._format_transform_reprc                 C   s   dS )NÚ r   r#   r   r   r   r0   T   r%   zVisionDataset.extra_repr)NNNN)r.   Ú
__module__Ú__qualname__Ú__doc__r'   r   r   r   r   r   r   Úintr   r!   r$   r8   r   rD   r0   r   r   r   r   r   
   s.    û
þýüû
ú
r   c                   @   sr   e Zd Zddee dee ddfdd„Zdededeeef fd	d
„Zdede	de
e	 fdd„Zde	fdd„ZdS )r   Nr   r   r   c                 C   s   || _ || _d S r"   ©r   r   )r   r   r   r   r   r   r   Y   s   
zStandardTransform.__init__ÚinputÚtargetc                 C   s0   | j d ur
|   |¡}| jd ur|  |¡}||fS r"   rK   )r   rL   rM   r   r   r   Ú__call__]   s
   



zStandardTransform.__call__r5   c                    r9   )Nr   c                    r:   r;   r<   r(   r?   r   r   r+   f   r@   z<StandardTransform._format_transform_repr.<locals>.<listcomp>rA   rB   rC   r   r?   r   rD   d   rE   z(StandardTransform._format_transform_reprc                 C   sL   | j jg}| jd ur||  | jd¡7 }| jd ur!||  | jd¡7 }d |¡S )NzTransform: zTarget transform: r,   )r-   r.   r   rD   r   r4   )r   r6   r   r   r   r8   h   s   



zStandardTransform.__repr__)NN)r.   rG   rH   r   r   r   r   r   rN   r   r   rD   r8   r   r   r   r   r   X   s
     r   )r   Úpathlibr   Útypingr   r   r   r   r   r   Útorch.utils.dataÚutilsÚdatar
   ÚDatasetr   r   r   r   r   r   Ú<module>   s     N