So I was working with a  problem of Siamese network which requires the dataloader to output two random images and 1/0 based on if they are of the same class.
class Siamese(Dataset):
    def __init__(self,train_df):
        self.train_df=train_df
      
    def __len__(self):
        return(len(self.train_df))
    
    def __getitem__(self,idx):
        if torch.is_tensor(idx):
            idx = idx.tolist()
        img1=self.train_df.iloc[random.randint(0,177),:]
        img2=self.train_df.iloc[random.randint(0,177),:]
        while(img1['target']!=img2['target']):
            IMG1=img1.iloc[0:-1]
            IMG2=img2.iloc[0:-1]
            return IMG1,IMG2, torch.from_numpy(np.array([img1['target']==img2['target']],dtype=np.float32))

data=Siamese(digits.data)
vis_dataloader = DataLoader(data,
                        shuffle=True,
                           batch_size=2)
dataiter = iter(vis_dataloader)
next(dataiter)

gave me an error
TypeError                                 Traceback (most recent call last)
 in 
----> 1 next(dataiter)
G:\ana\lib\site-packages\torch\utils\data\dataloader.py in next(self)
558         if self.num_workers == 0:  # same-process loading
559             indices = next(self.sample_iter)  # may raise StopIteration
–> 560             batch = self.collate_fn([self.dataset[i] for i in indices])
561             if self.pin_memory:
562                 batch = _utils.pin_memory.pin_memory_batch(batch)
G:\ana\lib\site-packages\torch\utils\data_utils\collate.py in default_collate(batch)
68         return [default_collate(samples) for samples in transposed]
69
—> 70     raise TypeError((error_msg_fmt.format(type(batch[0]))))
TypeError: batch must contain tensors, numbers, dicts or lists; found <class ‘NoneType’>
Sorry if this a real silly question, I am new to pytorch and coding.