code: def channel_to_kraus(chan: Channel) -> 'Kraus':
      
      qubits = chan.qubits
      N = chan.qubit_nb
  
      choi = asarray(chan.choi())
      evals, evecs = np.linalg.eig(choi)
      evecs = np.transpose(evecs)
  
      assert np.allclose(evals.imag, 0.0)  # FIXME exception
      assert np.all(evals.real >= 0.0)     # FIXME exception
  
      values = np.sqrt(evals.real)
  
      ops = []
      for i in range(2**(2*N)):
          if not np.isclose(values[i], 0.0):
              mat = np.reshape(evecs[i], (2**N, 2**N))*values[i]
              g = Gate(mat, qubits)
              ops.append(g)
  
      return Kraus(ops)
docs: Convert a channel superoperator into a Kraus operator representation
      of the same channel.