def logout(self, return_to=None, name_id=None, session_index=None, nq=None, name_id_format=None):
slo_url = self.get_slo_url()<EOL>if slo_url is None:<EOL><INDENT>raise OneLogin_Saml2_Error(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_Error.SAML_SINGLE_LOGOUT_NOT_SUPPORTED<EOL>)<EOL><DEDENT>if name_id is None and self.__nameid is not None:<EOL><INDENT>name_id = self.__nameid<EOL><DEDENT>if name_id_format is None and self.__nameid_format is not None:<EOL><INDENT>name_id_format = self.__nameid_format<EOL><DEDENT>logout_request = OneLogin_Saml2_Logout_Request(<EOL>self.__settings,<EOL>name_id=name_id,<EOL>session_index=session_index,<EOL>nq=nq,<EOL>name_id_format=name_id_format<EOL>)<EOL>self.__last_request = logout_request.get_xml()<EOL>self.__last_request_id = logout_request.id<EOL>saml_request = logout_request.get_request()<EOL>parameters = {'<STR_LIT>': logout_request.get_request()}<EOL>if return_to is not None:<EOL><INDENT>parameters['<STR_LIT>'] = return_to<EOL><DEDENT>else:<EOL><INDENT>parameters['<STR_LIT>'] = OneLogin_Saml2_Utils.get_self_url_no_query(self.__request_data)<EOL><DEDENT>security = self.__settings.get_security_data()<EOL>if security.get('<STR_LIT>', False):<EOL><INDENT>parameters['<STR_LIT>'] = security['<STR_LIT>']<EOL>parameters['<STR_LIT>'] = self.build_request_signature(saml_request, parameters['<STR_LIT>'], security['<STR_LIT>'])<EOL><DEDENT>return self.redirect_to(slo_url, parameters)<EOL>
Initiates the SLO process.

:param return_to: Optional argument. The target URL the user should be redirected to after logout.
:type return_to: string

:param name_id: The NameID that will be set in the LogoutRequest.
:type name_id: string

:param session_index: SessionIndex that identifies the session of the user.
:type session_index: string

:param nq: IDP Name Qualifier
:type: string

:param name_id_format: The NameID Format that will be set in the LogoutRequest.
:type: string

:returns: Redirection url