<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_unused(self, keyword_ids=None):
 """ Removes all instances that are not assigned to any object. Limits processing to ``keyword_ids`` if given. """

        if keyword_ids is None:
            keywords = self.all()
        else:
            keywords = self.filter(id__in=keyword_ids)
        keywords.filter(assignments__isnull=True).delete()