Hello everyone,
So, I am working on a small project and I am kind of stuck for like 2 hours now on a thing that seems simple so I would be very thankful if anyone can help.
So, I have a list of tensors that I called new_images and a list of labels.
I want to create a dataloader using these two.
So, I tried several things like for example a dumb list of tuples but it did not work. It showed an error but I ignored it because I know that this kind of  solution would not work.
I tried creating a class dataset like this:
class DataSetCos(torch.utils.data.Dataset):
    def __init__(self, nbr_samples, new_images, new_labels, transform=None):
        self.nbr_samples=nbr_samples
        self.labels=new_labels
        self.transform = transform
    def __len__(self):
        return self.nbr_samples
    def __getitem__(self, idx):
        if torch.is_tensor(idx):
            idx = idx.tolist()
        sample = new_images[idx]
        if self.transform:
            sample = self.transform(sample)
        if (sample.float().size()[0] == 3):
            return [sample.float(), self.labels[idx]]

after that I loaded it like this:
dataset= DataSetCos(nbr_samples=100, new_images=new_images, new_labels=new_labels, transform =None)
dataloader= torch.utils.data.DataLoader(dataset,batch_size=batch_size,shuffle=False)

but when I try testing my model, I get this error IndexError: list index out of range.