code: def bloch_decomposition(gate: Gate) -> Circuit:
      
      if gate.qubit_nb != 1:
          raise ValueError('Expected 1-qubit gate')
  
      U = asarray(gate.asoperator())
      U /= np.linalg.det(U) ** (1/2)
  
      nx = - U[0, 1].imag
      ny = - U[0, 1].real
      nz = - U[0, 0].imag
      N = np.sqrt(nx**2 + ny**2 + nz**2)
      if N == 0:  # Identity
          nx, ny, nz = 1, 1, 1
      else:
          nx /= N
          ny /= N
          nz /= N
      sin_halftheta = N
      cos_halftheta = U[0, 0].real
      theta = 2 * np.arctan2(sin_halftheta, cos_halftheta)
  
      # We return a Circuit (rather than just a gate) to keep the
      # interface of decomposition routines uniform.
      return Circuit([RN(theta, nx, ny, nz, *gate.qubits)])
docs: Converts a 1-qubit gate into a RN gate, a 1-qubit rotation of angle theta
      about axis (nx, ny, nz) in the Bloch sphere.
  
      Returns:
          A Circuit containing a single RN gate