
    Pj                         d dl Z d dlmZ d dlmZmZmZmZmZ d dl	m
c mZ ddl
mZ  edd          Z G d	 d
ej        e                   Z G d d          ZdS )    N)Path)AnyCallableOptionalTypeVarUnion   )_log_api_usage_onceT_coT)	covariantc                       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          ^/var/www/html/Carbon-Document/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__:   s
     "!r"   c                     t           Nr%   r   s    r    __len__zVisionDataset.__len__D   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>O   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__G   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"   r<   c                     |                                                                 } |d          gfd|dd          D             z   S )Nr   c                 \    g | ](}d                      dt                    z  |          )S z{}{}r.   formatlenr0   r1   r<   s     r    r2   z8VisionDataset._format_transform_repr.<locals>.<listcomp>T   2    'c'c'cQUcCIIot(L(L'c'c'cr"      r?   r8   r   r   r<   r>   s     ` r    _format_transform_reprz$VisionDataset._format_transform_reprR   _    ""$$//11#q##$'c'c'c'cY^_`_a_aYb'c'c'cccr"   c                     dS )N  r*   s    r    r7   zVisionDataset.extra_reprV   s    rr"   )NNNN)r5   
__module____qualname____doc__r/   r   r   r   r   r   r!   intr   r'   r+   r?   listrK   r7   rO   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__[   s    " 0r"   inputtargetc                 z    | j         |                      |          }| j        |                     |          }||fS r)   rW   )r   rX   rY   s      r    __call__zStandardTransform.__call___   sA    >%NN5))E ,**622Ff}r"   r<   c                     |                                                                 } |d          gfd|dd          D             z   S )Nr   c                 \    g | ](}d                      dt                    z  |          )S rB   rC   rF   s     r    r2   z<StandardTransform._format_transform_repr.<locals>.<listcomp>h   rG   r"   rH   rI   rJ   s     ` r    rK   z(StandardTransform._format_transform_reprf   rL   r"   c                     | j         j        g}| j        ||                     | j        d          z  }| j        ||                     | j        d          z  }d                    |          S )NzTransform: zTarget transform: r3   )r4   r5   r   rK   r   r;   )r   r=   s     r    r?   zStandardTransform.__repr__j   sj    '(>%D//NNND ,D//0EG[\\\Dyyr"   )NN)r5   rP   rQ   r   r   r!   r   tupler[   r   rT   rK   r?   rO   r"   r    r   r   Z   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   r   torch.utils.datautilsdatar
   r   Datasetr   r   rO   r"   r    <module>rf      s    				       : : : : : : : : : : : : : :          ' ' ' ' ' 'wv&&&K K K K KDL& K K K\         r"   