You could just sample another index which is different to the one you are getting in __getitem__(self, index) and return this negative sample.
Something like this should work:
class MyDataset(Dataset):
    def __init__(self):
        self.data = torch.randn(100, 1)
        
    def __getitem__(self, index):
        x = self.data[index]
        index_neg = torch.randint(0, self.__len__(), (1,))
        while index_neg==index:
            index_neg = torch.randint(0, self.__len__(), (1,))
        x_neg = self.data[index_neg]
        print('Using {} and {}'.format(index, index_neg))
        return x, x_neg
        
    def __len__(self):
        return len(self.data)

dataset = MyDataset()