def _generate_choices_from_rules(self) -> tuple[np.ndarray, np.ndarray]:
        """Generate choices from Alice and Bob's measurements by inferring the third number from the
        first two.

        Returns:
            Alice and Bob's choices in the game.
        """
        repetitions = self.alice_measurements.shape[2]
        alice_choices = np.zeros((3, 3, repetitions, 3), dtype=bool)
        bob_choices = np.zeros((3, 3, repetitions, 3), dtype=bool)
        alice_choices[0, :, :, 0] = self.alice_measurements[0, :, :, 1]
        alice_choices[0, :, :, 1] = self.alice_measurements[0, :, :, 0]
        alice_choices[1, :, :, :2] = self.alice_measurements[1, :, :, :2]
        alice_choices[2, :, :, :2] = 1 - self.alice_measurements[2, :, :, :2]
        bob_choices[:, 0, :, 0] = self.bob_measurements[:, 0, :, 1]
        bob_choices[:, 0, :, 1] = self.bob_measurements[:, 0, :, 0]
        bob_choices[:, 1:, :, :2] = self.bob_measurements[:, 1:, :, :2]
        alice_choices[:, :, :, 2] = np.sum(alice_choices, axis=3) % 2
        bob_choices[:, :, :, 2] = 1 - (np.sum(bob_choices, axis=3) % 2)
        assert np.all((np.sum(alice_choices, axis=3) % 2) == 0)
        assert np.all((np.sum(bob_choices, axis=3) % 2) == 1)
        return alice_choices, bob_choices
Generate choices from Alice and Bob's measurements by inferring the third number from the
        first two.

        Returns:
            Alice and Bob's choices in the game.
        
examples/magic_square.py