I think the easiest approach would be to write a custom Dataset, and load the desired samples inside of __init__.
Since the data format is different for MNIST and CIFAR (size and number of channels), you would also need to specify some dataset-specific transformations.
Here is a small sample code, which could be a good starter:
class MyDataset(Dataset):
    def __init__(self, mnist_transform=None, cifar_transform=None):
        mnist = datasets.MNIST(
            root='./data',
        )
        cifar = datasets.CIFAR10(
            root='./data',
        )
        
        self.mnist_len = 100
        self.cifar_len = 10
        
        rand_idx = torch.randperm(len(mnist.data))[:self.mnist_len]
        self.mnist_data = mnist.data[rand_idx]
        
        rand_idx = torch.randperm(len(cifar.data))[:self.cifar_len]
        self.cifar_data = cifar.data[rand_idx]

        self.mnist_transform = mnist_transform
        self.cifar_transform = cifar_transform
        
    def __getitem__(self, index):
        if index < self.mnist_len:
            x = self.mnist_data[index]
            if self.mnist_transform:
                x = self.mnist_transform(x)
            print('Returning MNIST sample at index {}'.format(index))
            return x
        else:
            index = index - self.mnist_len
            x = self.cifar_data[index]
            if self.cifar_transform:
                x = self.cifar_transform(x)
            print('Returning CIFAR data at index {}'.format(index))
            return x
        
    def __len__(self):
        return self.mnist_len + self.cifar_len

        

mnist_transform = transforms.Compose([
    transforms.ToPILImage(),
    transforms.Resize((32, 32)),
    transforms.Grayscale(num_output_channels=3),
    transforms.ToTensor(),
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
    
cifar_transform = transforms.Compose([
    transforms.ToPILImage(),
    transforms.ToTensor(),
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
    
dataset = MyDataset(
    mnist_transform=mnist_transform,
    cifar_transform=cifar_transform
)