def matrix(self, qubits: Iterable[TKey] | None = None) -> np.ndarray:
        """Returns the matrix of self in computational basis of qubits.

        Args:
            qubits: Ordered collection of qubits that determine the subspace
                in which the matrix representation of the Pauli string is to
                be computed. Qubits absent from `self.qubits` are acted on by
                the identity. Defaults to `self.qubits`.

        Raises:
            NotImplementedError: If this PauliString is parameterized.
        """
        qubits = self.qubits if qubits is None else qubits
        factors = [self.get(q, default=identity.I) for q in qubits]
        if protocols.is_parameterized(self):
            raise NotImplementedError('Cannot express as matrix when parameterized')
        assert isinstance(self.coefficient, complex)
        return linalg.kron(self.coefficient, *[protocols.unitary(f) for f in factors])
Returns the matrix of self in computational basis of qubits.

        Args:
            qubits: Ordered collection of qubits that determine the subspace
                in which the matrix representation of the Pauli string is to
                be computed. Qubits absent from `self.qubits` are acted on by
                the identity. Defaults to `self.qubits`.

        Raises:
            NotImplementedError: If this PauliString is parameterized.
        
cirq-core/cirq/ops/pauli_string.py