Earlier it was very easy and straightforward to get counts for all classical registers using just one line of code:
counts = backend.run(qc, shots=1000).result().get_counts()
However, when I run such code on QPU I'm getting a warning that such call is deprecated and will be removed soon and a link to a documentation how to use the new SamplerV2 instead.
Using SamplerV2 I can get the 'combined' counts in such way:
job = sampler.run([qc])
result = job.result()[0]
counts = result.data.meas.get_counts()
The problem is that if I want to use the meas property I need to invoke measure_all() on the circuit. Otherwise I have to obtain count for each register individually in such way:
counts_c_reg0 = result.data.c_reg0.get_counts()
However, such approach brings some problems. First of all, it is quite messy and error-prone to use a register name as a property in results. Also for my algo the value of one register measurement has no sense and I need to analyse the output in total for all registers (for example, how many times 101 was measured in one shot and so on). Additionally I can't use measure_all() as measurements happen on my circuit on different stages.
How can I get combined counts when using qiskit_ibm_runtime.SamplerV2? Or using any other 'modern' approach without having 'deprecated' warnings.