def to_instruction(self):
from qiskit.circuit.instruction import Instruction<EOL>n_qubits = int(np.log2(self._input_dim))<EOL>if self._input_dim != self._output_dim or <NUM_LIT:2>**n_qubits != self._input_dim:<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>if not self.is_cptp():<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>kraus, _ = _to_kraus(self.rep, self._data, *self.dim)<EOL>if len(kraus) == <NUM_LIT:1>:<EOL><INDENT>return Operator(kraus[<NUM_LIT:0>]).to_instruction()<EOL><DEDENT>return Instruction('<STR_LIT>', n_qubits, <NUM_LIT:0>, kraus)<EOL>
Convert to a Kraus or UnitaryGate circuit instruction.

        If the channel is unitary it will be added as a unitary gate,
        otherwise it will be added as a kraus simulator instruction.

        Returns:
            Instruction: A kraus instruction for the channel.

        Raises:
            QiskitError: if input data is not an N-qubit CPTP quantum channel.