
    Yh                         d dl Z d dlmZ d dlmZmZmZmZ d dlm	c m
Z
 ddl	mZ  G d de
j                  Z G d d	          ZdS )
    N)Path)AnyCallableOptionalUnion   )_log_api_usage_oncec                       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	Z
d
edefdZdefdZdefdZde	dedee         fdZdef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                 &   t          |            t          |t                    rt          j                            |          }|| _        |d u}|d up|d u}|r|rt          d          || _        || _	        |rt          ||          }|| _        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   has_transformshas_separate_transforms          m/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torchvision/datasets/vision.py__init__zVisionDataset.__init__   s     	D!!!dC   	,7%%d++D	#4/!*$!6!V:JRV:V 	h4 	hfggg # 0! 	H*96FGGJ$    indexc                     t           )z
        Args:
            index (int): Index

        Returns:
            (Any): Sample and meta data, optionally transformed by the respective transforms.
        NotImplementedError)r   r    s     r   __getitem__zVisionDataset.__getitem__8   s
     "!r   c                     t           Nr"   r   s    r   __len__zVisionDataset.__len__B   s    !!r   c                     d j         j        z   }d                                  g} j        |                    d j                    |                                                                 z  }t           d          r j        |t           j                  gz  }|g fd|D             z   }d
                    |          S )NzDataset zNumber of datapoints: zRoot location: r   c                 *    g | ]}d j         z  |z   S ) )_repr_indent).0liner   s     r   
<listcomp>z*VisionDataset.__repr__.<locals>.<listcomp>M   s&    JJJT# 11D8JJJr   
)	__class____name__r(   r   append
extra_repr
splitlineshasattrr   reprjoin)r   headbodyliness   `   r   __repr__zVisionDataset.__repr__E   s    DN33999:9 KK5$)55666!!,,...4&& 	,4?+FT$/**++DJJJJTJJJJyyr   r9   c                     |                                                                 } |d          gfd|dd          D             z   S )Nr   c                 \    g | ](}d                      dt                    z  |          )S z{}{}r+   formatlenr-   r.   r9   s     r   r/   z8VisionDataset._format_transform_repr.<locals>.<listcomp>R   2    'c'c'cQUcCIIot(L(L'c'c'cr      r<   r5   r   r   r9   r;   s     ` r   _format_transform_reprz$VisionDataset._format_transform_reprP   _    ""$$//11#q##$'c'c'c'cY^_`_a_aYb'c'c'cccr   c                     dS )N  r'   s    r   r4   zVisionDataset.extra_reprT   s    rr   )NNNN)r2   
__module____qualname____doc__r,   r   r   r   r   r   r   intr   r$   r(   r<   listrH   r4   rL   r   r   r   r   
   s;        $ L "&)-(,/3% %CI% X&% H%	%
 #8,% 
% % % %2" " " " " "" " " " "	 # 	  	  	  	 d d dS	 d d d dC      r   r   c                       e Zd Zddee         dee         ddfdZdededeeef         fdZded	e	de
e	         fd
Zde	fdZdS )r   Nr   r   r   c                 "    || _         || _        d S r&   r   r   )r   r   r   s      r   r   zStandardTransform.__init__Y   s    " 0r   inputtargetc                 z    | j         |                      |          }| j        |                     |          }||fS r&   rT   )r   rU   rV   s      r   __call__zStandardTransform.__call__]   sA    >%NN5))E ,**622Ff}r   r9   c                     |                                                                 } |d          gfd|dd          D             z   S )Nr   c                 \    g | ](}d                      dt                    z  |          )S r?   r@   rC   s     r   r/   z<StandardTransform._format_transform_repr.<locals>.<listcomp>f   rD   r   rE   rF   rG   s     ` r   rH   z(StandardTransform._format_transform_reprd   rI   r   c                     | j         j        g}| j        ||                     | j        d          z  }| j        ||                     | j        d          z  }d                    |          S )NzTransform: zTarget transform: r0   )r1   r2   r   rH   r   r8   )r   r:   s     r   r<   zStandardTransform.__repr__h   sj    '(>%D//NNND ,D//0EG[\\\Dyyr   )NN)r2   rM   rN   r   r   r   r   tuplerX   r   rQ   rH   r<   rL   r   r   r   r   X   s        1 1(8"4 1xX`Oa 1mq 1 1 1 1c 3 5c?    d d dS	 d d d d#      r   r   )r   pathlibr   typingr   r   r   r   torch.utils.datautilsdatar	   Datasetr   r   rL   r   r   <module>rc      s    				       1 1 1 1 1 1 1 1 1 1 1 1          ' ' ' ' ' 'K K K K KDL K K K\         r   