def _get_all_qubits(
    circuit: cirq.AbstractCircuit, observables: Iterable[cirq.PauliString]
) -> list[cirq.Qid]:
    """Helper function for `measure_observables` to get all qubits from a circuit and a
    collection of observables."""
    qubit_set = set()
    for obs in observables:
        qubit_set |= set(obs.qubits)
    qubit_set |= circuit.all_qubits()
    return sorted(qubit_set)
Helper function for `measure_observables` to get all qubits from a circuit and a
    collection of observables.
cirq-core/cirq/work/observable_measurement.py