Well, it's not vectorized, but something like the following should work, only there appears to be a bug in it:
```python
from scipy import stats

        rank = stats.rankdata(y_score[i], 'max')
        true_mask = ~y_true[i].astype(bool)
        masked_score = np.ma.masked_array(y_score[i], mask=true_mask)
        L = np.ma.masked_array(stats.mstats.rankdata(masked_score),
                               mask=true_mask)
        print(rank, L, np.divide(L, rank, dtype=float))

        score += np.divide(L, rank, dtype=float).mean()

```