
    ڧg<                     v    d dl Zd dlmZ d dlmZmZmZ d dlZ	d dl
Z
d dlmZmZ d dlmZ  G d de          ZdS )    N)Path)CallableOptionalUnion)download_urlverify_str_arg)VisionDatasetc                        e Zd ZdZdZ	 	 	 	 ddeeef         dee         de	d	e
d
ee         ddf fdZde	dej        fdZde	fdZde
fdZddZ xZS )MovingMNISTaE  `MovingMNIST <http://www.cs.toronto.edu/~nitish/unsupervised_video/>`_ Dataset.

    Args:
        root (str or ``pathlib.Path``): Root directory of dataset where ``MovingMNIST/mnist_test_seq.npy`` exists.
        split (string, optional): The dataset split, supports ``None`` (default), ``"train"`` and ``"test"``.
            If ``split=None``, the full data is returned.
        split_ratio (int, optional): The split ratio of number of frames. If ``split="train"``, the first split
            frames ``data[:, :split_ratio]`` is returned. If ``split="test"``, the last split frames ``data[:, split_ratio:]``
            is returned. If ``split=None``, this parameter is ignored and the all frames data is returned.
        transform (callable, optional): A function/transform that takes in a torch Tensor
            and returns a transformed version. E.g, ``transforms.RandomCrop``
        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.
    zGhttp://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npyN
   Frootsplitsplit_ratiodownload	transformreturnc                    t                                          ||           t          j                            | j        | j        j                  | _        | j	        
                    d          d         | _        |t          |dd           || _
        t          |t                    st          dt!          |                     d|cxk    rdk    sn t#          d	| d
          || _        |r|                                  |                                 st+          d          t-          j        t1          j        t          j                            | j        | j                                      }| j
        dk    r|d | j                 }n| j
        dk    r|| j        d          }|                    dd                              d                                          | _        d S )N)r   /r   )traintestz,`split_ratio` should be an integer, but got       z:`split_ratio` should be `1 <= split_ratio <= 19`, but got z	 instead.z<Dataset not found. You can use download=True to download it.r   r   r      )super__init__ospathjoinr   	__class____name___base_folder_URLr   	_filenamer   
isinstanceint	TypeErrortype
ValueErrorr   r   _check_existsRuntimeErrortorch
from_numpynpload	transpose	unsqueeze
contiguousdata)selfr   r   r   r   r   r3   r    s          ]/var/www/html/ai-engine/env/lib/python3.11/site-packages/torchvision/datasets/moving_mnist.pyr   zMovingMNIST.__init__   s    	333GLLDN4KLL--b15'+<===
+s++ 	r^4P[K\K\^^___{((((b((((pZepppqqq& 	MMOOO!!## 	_]^^^T5F(W(W X XYY:  *$**+DDZ6!!(**+DNN1a((22155@@BB			    idxc                 X    | j         |         }| j        |                     |          }|S )z
        Args:
            idx (int): Index
        Returns:
            torch.Tensor: Video frames (torch Tensor[T, C, H, W]). The `T` is the number of frames.
        )r3   r   )r4   r7   r3   s      r5   __getitem__zMovingMNIST.__getitem__B   s-     y~>%>>$''Dr6   c                 *    t          | j                  S N)lenr3   r4   s    r5   __len__zMovingMNIST.__len__O   s    49~~r6   c                     t           j                            t           j                            | j        | j                            S r;   )r   r   existsr   r"   r$   r=   s    r5   r*   zMovingMNIST._check_existsR   s+    w~~bgll4+<dnMMNNNr6   c                 v    |                                  rd S t          | j        | j        | j        d           d S )N be083ec986bfe91a449d63653c411eb2)urlr   filenamemd5)r*   r   r#   r"   r$   r=   s    r5   r   zMovingMNIST.downloadU   sO     	F	"^2		
 	
 	
 	
 	
 	
r6   )Nr   FN)r   N)r!   
__module____qualname____doc__r#   r   strr   r   r&   boolr   r   r,   Tensorr9   r>   r*   r   __classcell__)r    s   @r5   r   r      s/          UD
  $(,"C "CCI"C }"C 	"C
 "C H%"C 
"C "C "C "C "C "CHs u|        Ot O O O O	
 	
 	
 	
 	
 	
 	
 	
r6   r   )os.pathr   pathlibr   typingr   r   r   numpyr.   r,   torchvision.datasets.utilsr   r   torchvision.datasets.visionr	   r    r6   r5   <module>rT      s           , , , , , , , , , ,      C C C C C C C C 5 5 5 5 5 5S
 S
 S
 S
 S
- S
 S
 S
 S
 S
r6   