o
    h	                     @   sH   d dl mZmZmZ d dlZddlmZ ddlmZ G dd deZ	dS )	    )AnyCallableOptionalN   )
transforms   )VisionDatasetc                       s   e Zd ZdZ						ddedeeeef d	ed
ee dee deddf fddZdedee	e	f fddZ
defddZ  ZS )FakeDataa  A fake dataset that returns randomly generated images and returns them as PIL images

    Args:
        size (int, optional): Size of the dataset. Default: 1000 images
        image_size(tuple, optional): Size of the returned images. Default: (3, 224, 224)
        num_classes(int, optional): Number of classes in the dataset. Default: 10
        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.
        random_offset (int): Offsets the index-based random seed used to
            generate each image. Default: 0

            r   
   Nr   size
image_sizenum_classes	transformtarget_transformrandom_offsetreturnc                    s,   t  j||d || _|| _|| _|| _d S )N)r   r   )super__init__r   r   r   r   )selfr   r   r   r   r   r   	__class__ c/home/www/facesmatcher.com/frenv_anti/lib/python3.10/site-packages/torchvision/datasets/fakedata.pyr      s
   	
zFakeData.__init__indexc                 C   s   |t | krt| jj dt }t|| j  tj| j	 }tj
d| jdtjdd }t| t |}| jdurC| |}| jdurM| |}|| fS )z
        Args:
            index (int): Index

        Returns:
            tuple: (image, target) where target is class_index of the target class.
        z index out of ranger   )r   )r   ZdtypeN)len
IndexErrorr   __name__torchZget_rng_stateZmanual_seedr   Zrandnr   randintr   longZset_rng_stater   Z
ToPILImager   r   item)r   r   Z	rng_stateZimgtargetr   r   r   __getitem__(   s   	




zFakeData.__getitem__c                 C   s   | j S )N)r   )r   r   r   r   __len__B   s   zFakeData.__len__)r
   r   r   NNr   )r    
__module____qualname____doc__inttupler   r   r   r   r&   r'   __classcell__r   r   r   r   r	   	   s2    r	   )
typingr   r   r   r!    r   Zvisionr   r	   r   r   r   r   <module>   s
    