From what I understand, torchvision.transforms only work with one image at a time and not a batch of images. I guess this should do.
#initialise the class variables - transform, data, target
def __init__(self, data, target, transform=None): 
    self.transform = transform     
    self.data =  data
    # converting target to torch.LongTensor dtype
    self.target = target 

#retrieve the X and y index value and return it
def __getitem__(self, index):   
    return (self.transform(self.data[index]).view(1, -1), self.target[index])

#returns the length of the data
def __len__(self): 
    return len(list(self.data))