+parser.add_argument('--data',
+ type = str, default = 'image_pair',
+ help = 'What data')
+
+parser.add_argument('--seed',
+ type = int, default = 0,
+ help = 'Random seed (default 0, < 0 is no seeding)')
+
+parser.add_argument('--mnist_classes',
+ type = str, default = '0, 1, 3, 5, 6, 7, 8, 9',
+ help = 'What MNIST classes to use')
+
+######################################################################
+
+args = parser.parse_args()
+
+if args.seed >= 0:
+ torch.manual_seed(args.seed)
+
+used_MNIST_classes = torch.tensor(eval('[' + args.mnist_classes + ']'))
+
+######################################################################
+
+train_set = torchvision.datasets.MNIST('./data/mnist/', train = True, download = True)
+train_input = train_set.train_data.view(-1, 1, 28, 28).float()
+train_target = train_set.train_labels
+
+test_set = torchvision.datasets.MNIST('./data/mnist/', train = False, download = True)
+test_input = test_set.test_data.view(-1, 1, 28, 28).float()
+test_target = test_set.test_labels
+
+if torch.cuda.is_available():
+ used_MNIST_classes = used_MNIST_classes.cuda()
+ train_input, train_target = train_input.cuda(), train_target.cuda()
+ test_input, test_target = test_input.cuda(), test_target.cuda()
+
+mu, std = train_input.mean(), train_input.std()
+train_input.sub_(mu).div_(std)
+test_input.sub_(mu).div_(std)
+
+######################################################################
+
+# Returns a triplet of tensors (a, b, c), where a and b contain each
+# half of the samples, with a[i] and b[i] of same class for any i, and
+# c is a 1d long tensor with the count of pairs per class used.
+
+def create_image_pairs(train = False):