code: def create_union_mnist_dataset():
    
    transform = transforms.Compose([transforms.ToTensor(),
                                    transforms.Normalize((0.1307,), (0.3081,))])
  
    mnist1 = datasets.MNIST('data', train=False, download=True, transform=transform)
    data1 = zip(mnist1.test_data, mnist1.test_labels)
  
    # Randomize second dataset
    mnist2 = datasets.MNIST('data', train=False, download=True, transform=transform)
    data2 = zip(mnist2.test_data, mnist2.test_labels)
    random.shuffle(data2)
  
    # Reorder images of second dataset with same label as first dataset
    for i in range(len(data2)):
      if data1[i][1] == data2[i][1]:
        # Swap indices with same label to a location with diffent label
        for j in range(len(data1)):
          if data1[i][1] != data2[j][1] and data2[i][1] != data1[j][1]:
            swap = data2[j]
            data2[j] = data2[i]
            data2[i] = swap
            break
  
    # Update second dataset with new item order
    mnist2.test_data, mnist2.test_labels = zip(*data2)
  
    # Combine the images of both datasets using the maximum value for each pixel
    return UnionDataset(datasets=[mnist1, mnist2],
                        transform=lambda x, y: torch.max(x, y))
docs: Create a UnionDataset composed of two versions of the MNIST datasets
    where each item in the dataset contains 2 distinct images superimposed