code: def is_unitary(matrix: np.ndarray) -> bool:
      
      rows, cols = matrix.shape
      if rows != cols:
          return False
      return np.allclose(np.eye(rows), matrix.dot(matrix.T.conj()))
docs: A helper function that checks if a matrix is unitary.
  
      :param matrix: a matrix to test unitarity of
      :return: true if and only if matrix is unitary