<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def defer(target, args=None, kwargs=None, callback=None):
 """Perform operation in thread with callback Instances are cached until finished, at which point they are garbage collected. If we didn't do this, Python would step in and garbage collect the thread before having had time to finish, resulting in an exception. Arguments: target (callable):
 Method or function to call callback (callable, optional):
 Method or function to call once `target` has finished. Returns: None """


    obj = _defer(target, args, kwargs, callback)
    obj.finished.connect(lambda: _defer_cleanup(obj))
    obj.start()
    _defer_threads.append(obj)
    return obj