+ correct = (quizzes == result).long().min(dim=-1).values
+
+ reverse_result = reverse_quizzes.clone()
+
+ masked_inplace_autoregression(
+ m,
+ self.batch_size,
+ reverse_result,
+ ar_mask,
+ deterministic_synthesis=True,
+ progress_bar_desc="solving reversed quizzes",
+ device=self.device,
+ )
+
+ reverse_correct = (
+ (reverse_quizzes == reverse_result).long().min(dim=-1).values
+ )
+
+ nb_correct.append((correct * reverse_correct)[None, :])
+
+ nb_correct = torch.cat(nb_correct, dim=0)
+
+ filename = os.path.join(result_dir, "correct_{n_epoch:04d}.dat")
+ with open(filename, "w") as f:
+ for k in nb_correct:
+ f.write(f"{k}\n")