<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_debugged_thread(self, target_thread_ident=None):
 """ Allows to reset or set the thread to debug. """

        if target_thread_ident is None:
            self.debugged_thread_ident = None
            self.debugged_thread_name = ''
            return {
                "result": self.get_threads(),
                "error": ""
            }
            
        thread_list = self.get_threads()
        if target_thread_ident not in thread_list:
            return {
                "result": None,
                "error": "No thread with ident:%s." % target_thread_ident
            }
        
        if thread_list[target_thread_ident]['is_debugger']:
            return {
                "result": None,
                "error": "Cannot debug IKPdb tracer (sadly...)."
            }
        
        self.debugged_thread_ident = target_thread_ident
        self.debugged_thread_name = thread_list[target_thread_ident]['name']
        return {
            "result": self.get_threads(),
            "error": ""
        }