Ok I think I understand your intention with the code now. Sorry I was wrong before. I think what you're talking about here is what gets called the "detection loophole" in most of the literatire. The idea that if we detect only a small enough fraction of the events then they can be a sufficiently unrepresentative sample that we think we violated a Bell inequality even though the full statistics don't.
This has (in my opinion) been comprehensively addressed already. You can check out the references in the section of the wiki article here
https://en.wikipedia.org/wiki/Bell_test#Detection_loophole
but basically if you detect enough of the possible events in the experiment there is no way for nature to "trick" you in this way, "enough" is 83% for the standard CHSH inequality or 66% if you use a slightly modified. Recent experiments (in the last decade or so) are substantially over the threshold for the detection loophole to be a problem. This is one of the earliest papers where this loophole was closed with space-like seperated detectors from 2015. In this paper they used entangled NV centers in diamond as their qubits of choice, and so essentialy had zero events lost.
https://arxiv.org/abs/1508.05949
This is a second one from the same time. This one uses a more standard setup with photons and worked with about 75% detector efficiency for each party (well above the 66% required)
https://arxiv.org/abs/1511.03189
And this is a third with an efficiency of 78% for Alice and 76% for Bob
https://arxiv.org/abs/1511.03190
I therefore have a new challenge - break the CHSH inequality, while rejecting fewer than 17% of the events, or break the (easier) modified Bell inequality used in papers 2 & 3 while rejecting fewer than a third.
Edit: This is another, more recent paper where they use superconducting qubits and again lose no events
https://www.nature.com/articles/s41586-023-05885-0