def probabilities(self, key: str | None = None) -> dict[int, float]:
        """Returns the probabilities of the measurement results.

        If a key parameter is supplied, these are the probabilities 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 probability that the corresponding bit string occurred.

        See `to_cirq_result` to convert to a `cirq.Result`.
        """
        if key is None:
            return self._probabilities
        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.'
            )
        targets = self._measurement_dict[key]
        result: dict[int, float] = dict()
        for value, probability in self._probabilities.items():
            bits = [(value >> (self.num_qubits() - target - 1)) & 1 for target in targets]
            bit_value = sum(bit * (1 << i) for i, bit in enumerate(bits[::-1]))
            if bit_value in result:
                result[bit_value] += probability
            else:
                result[bit_value] = probability
        return result
Returns the probabilities of the measurement results.

        If a key parameter is supplied, these are the probabilities 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 probability that the corresponding bit string occurred.

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