def __getitem__(self, index):
        """
        Args:
            index (int): Index

        Returns:
            tuple: (image, target) where target is class_index of the target class.
        """
        # create random image that is consistent with the index id
        if index >= len(self):
            raise IndexError("{} index out of range".format(self.__class__.__name__))
        rng_state = torch.get_rng_state()
        torch.manual_seed(index + self.random_offset)
        img = torch.randn(*self.image_size)
        target = torch.randint(0, self.num_classes, size=(1,), dtype=torch.long)[0]
        torch.set_rng_state(rng_state)

        # convert to PIL Image
        img = transforms.ToPILImage()(img)
        if self.transform is not None:
            img = self.transform(img)
        if self.target_transform is not None:
            target = self.target_transform(target)

        return img, target
def __getitem__ ( self , index ) : if index >= len ( self ) : raise IndexError ( "{} index out of range" . format ( self . __class__ . __name__ ) ) rng_state = torch . get_rng_state ( ) torch . manual_seed ( index + self . random_offset ) img = torch . randn ( * self . image_size ) target = torch . randint ( 0 , self . num_classes , size = ( 1 , ) , dtype = torch . long ) [ 0 ] torch . set_rng_state ( rng_state ) img = transforms . ToPILImage ( ) ( img ) if self . transform is not None : img = self . transform ( img ) if self . target_transform is not None : target = self . target_transform ( target ) return img , target
Args:
            index (int): Index

        Returns:
            tuple: (image, target) where target is class_index of the target class.