
    h                     v    S SK rS SKJr  S SKJrJrJrJr  S SK	r
SSKJr  SSKJrJr  SSKJr   " S	 S
\5      rg)    N)Path)AnyCallableOptionalUnion   )_Image_fromarray   )check_integritydownload_url)VisionDatasetc                      ^  \ rS rSrSrSrSrSr   SS\\	\
4   S\\   S	\\   S
\SS4
U 4S jjjrS\S\\\4   4S jrS\4S jrS\4S jrSS jrSrU =r$ )SEMEION   a  `SEMEION <http://archive.ics.uci.edu/ml/datasets/semeion+handwritten+digit>`_ Dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of dataset where directory
        ``semeion.py`` exists.
    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.
    download (bool, optional): If true, downloads the dataset from the internet and
        puts it in root directory. If dataset is already downloaded, it is not
        downloaded again.

zMhttp://archive.ics.uci.edu/ml/machine-learning-databases/semeion/semeion.datazsemeion.data cb545d371d2ce14ec121470795a77432Nroot	transformtarget_transformdownloadreturnc                   > [         TU ]  XUS9  U(       a  U R                  5         U R                  5       (       d  [	        S5      e[
        R                  R                  U R                  U R                  5      n[        R                  " U5      nUS S 2S S24   S-  R                  S5      U l        [        R                  " U R                  S5      U l        [        R                  " US S 2SS 24   5      S   U l        g )N)r   r   zHDataset not found or corrupted. You can use download=True to download it      uint8)   r   r
   )super__init__r   _check_integrityRuntimeErrorospathjoinr   filenamenploadtxtastypedatareshapenonzerolabels)selfr   r   r   r   fpr(   	__class__s          T/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/semeion.pyr   SEMEION.__init__    s     	EUVMMO$$&&ijjWW\\$))T]]3zz"~ !TcT']S(009	JJtyy,7	jjag/2    indexc                     U R                   U   [        U R                  U   5      p2[        USS9nU R                  b  U R	                  U5      nU R
                  b  U R                  U5      nX#4$ )zn
Args:
    index (int): Index

Returns:
    tuple: (image, target) where target is index of the target class.
L)mode)r(   intr+   r	   r   r   )r,   r2   imgtargets       r/   __getitem__SEMEION.__getitem__7   sl     ii&DKK,>(?V s->>%..%C  ,**62F{r1   c                 ,    [        U R                  5      $ N)lenr(   )r,   s    r/   __len__SEMEION.__len__M   s    499~r1   c                     U R                   n[        R                  R                  XR                  5      n[        X R                  5      (       d  gg)NFT)r   r!   r"   r#   r$   r   md5_checksum)r,   r   fpaths      r/   r   SEMEION._check_integrityP   s8    yyT==1u&7&788r1   c                     U R                  5       (       a  g U R                  n[        U R                  XR                  U R
                  5        g r<   )r   r   r   urlr$   rA   )r,   r   s     r/   r   SEMEION.downloadW   s7      ""yyTXXt]]D4E4EFr1   )r(   r+   )NNT)r   N)__name__
__module____qualname____firstlineno____doc__rE   r$   rA   r   strr   r   r   boolr   r6   tupler   r9   r>   r   r   __static_attributes____classcell__)r.   s   @r/   r   r      s     ZCH5L
 )-/33CI3 H%3 #8,	3
 3 
3 3. sCx , $ G Gr1   r   )os.pathr!   pathlibr   typingr   r   r   r   numpyr%   utilsr	   r   r   visionr   r    r1   r/   <module>rX      s-      1 1  $ 0 !PGm PGr1   