def sparse(self, qubits: Sequence[cirq.Qid] | None = None) -> cirq.PauliString:
        """A `cirq.PauliString` version of this dense pauli string.

        Args:
            qubits: The qubits to apply the Paulis to. Defaults to
                `cirq.LineQubit.range(len(self))`.

        Returns:
            A `cirq.PauliString` with the non-identity operations from
            this dense pauli string applied to appropriate qubits.

        Raises:
            ValueError: If the number of qubits supplied does not match that of
                this instance.
        """
        if qubits is None:
            from cirq import devices

            qubits = devices.LineQubit.range(len(self))

        if len(qubits) != len(self):
            raise ValueError('Wrong number of qubits.')

        return pauli_string.PauliString(
            coefficient=self.coefficient,
            qubit_pauli_map={q: PAULI_GATES[p] for q, p in zip(qubits, self.pauli_mask) if p},
        )
A `cirq.PauliString` version of this dense pauli string.

        Args:
            qubits: The qubits to apply the Paulis to. Defaults to
                `cirq.LineQubit.range(len(self))`.

        Returns:
            A `cirq.PauliString` with the non-identity operations from
            this dense pauli string applied to appropriate qubits.

        Raises:
            ValueError: If the number of qubits supplied does not match that of
                this instance.
        
cirq-core/cirq/ops/dense_pauli_string.py