Hi,
I do not know about x-shot learning but if you want to get a subset of your dataset, you just need to change the __len__() function to return maximum size you want.
This function return the length of your dataset, so if you put a constant number or a function the current number, you get as much as you wanted.
 def __len__(self):
        return len(self.inputFolderDataset.imgs)/10 # any number will work


About your second question, DataLoader class can solve your problem. It ‘shuffle’ argument which can create random batches of your dataset.
Here is a snippet you can use.
from torch.utils.data import DataLoader
# your CustomData is defined here
custom_data = CustomData(*args)
train_loader = DataLoader(dataset=custom_data,
                          batch_size= 16 # batch size,
                          shuffle=True,  # this line do the random thing
                          num_workers=0)

Based on PyTorch, every epoch, it will generate different random numbers so you’ll get different images.
Good luck