refactored code: if `unique_counts` is requested, but neither `return_index`
nor `return_inverse` are, there is no need to call `argsort`, and the counting
of unique items can be sped up a lot.