Thanks for the explanation @ptrblck. I have made changes and it worked. Just 1 last doubt. Below
class Siamese(Dataset):
    def __init__(self):
        self.data0 = torch.randn(10, 3, 224, 224)
        self.target0 = torch.randint(0, 10, (10,))
        self.data1 = torch.randn(10, 3, 224, 224)
        self.target1 = torch.randint(0, 10, (10,))

you have used torch.randn function.
I have tried giving my own dataset as an object as like below previously:
   def __init__(self, dataset):
        super().__init__()
        self.dataset = dataset

Now, As I want to pass my own dataset over here, what am I supposed to pass it
for self.data0,self.target0,self.data1 ,self.target1 .
What instances should I make to make it work?