def counts(self, key: str | None = None) -> Counter[int]:
        """Returns the processed counts of the measurement results.

        If a key parameter is supplied, these are the counts for the measurement results for
        the qubits measured by the measurement gate with that key.  If no key is given, these
        are the measurement results from measuring all qubits in the circuit.

        The key in the returned dictionary is the computational basis state measured for the
        qubits that have been measured.  This is expressed in big-endian form. For example, if
        no measurement key is supplied and all qubits are measured, the key in this returned dict
        has a bit string where the `cirq.LineQubit`s are expressed in the order:
            (cirq.LineQubit(0), cirq.LineQubit(1), ..., cirq.LineQubit(n-1))
        In the case where only `r` qubits are measured corresponding to targets t_0, t_1,...t_{r-1},
        the bit string corresponds to the order
            (cirq.LineQubit(t_0), cirq.LineQubit(t_1), ... cirq.LineQubit(t_{r-1}))

        The value is the number of times that corresponding bit string occurred.

        See `to_cirq_result` to convert to a `cirq.Result`.
        """
        if key is None:
            return collections.Counter(self._counts)
        if not key in self._measurement_dict:
            raise ValueError(
                f'Measurement key {key} is not a key for a measurement gate in the'
                'circuit that produced these results.'
            )
        result: Counter[int] = collections.Counter()
        result.update([bit_value for bit_value in self.ordered_results(key)])
        return result
Returns the processed counts of the measurement results.

        If a key parameter is supplied, these are the counts for the measurement results for
        the qubits measured by the measurement gate with that key.  If no key is given, these
        are the measurement results from measuring all qubits in the circuit.

        The key in the returned dictionary is the computational basis state measured for the
        qubits that have been measured.  This is expressed in big-endian form. For example, if
        no measurement key is supplied and all qubits are measured, the key in this returned dict
        has a bit string where the `cirq.LineQubit`s are expressed in the order:
            (cirq.LineQubit(0), cirq.LineQubit(1), ..., cirq.LineQubit(n-1))
        In the case where only `r` qubits are measured corresponding to targets t_0, t_1,...t_{r-1},
        the bit string corresponds to the order
            (cirq.LineQubit(t_0), cirq.LineQubit(t_1), ... cirq.LineQubit(t_{r-1}))

        The value is the number of times that corresponding bit string occurred.

        See `to_cirq_result` to convert to a `cirq.Result`.
        
cirq-ionq/cirq_ionq/results.py