Since `(predictions[mask])[:, p]` returns a copy, the idea is to do the same but on the flattened array. I edited the code so as to use your notation. Again it's not tested and might not work.