<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cleanup_containers(self, include_initial=False, exclude=None, raise_on_error=False, list_only=False):
 """ Finds all stopped containers and removes them; by default does not remove containers that have never been started. :param include_initial: Consider containers that have never been started. :type include_initial: bool :param exclude: Container names to exclude from the cleanup process. :type exclude: collections.Iterable[unicode | str] :param raise_on_error: Forward errors raised by the client and cancel the process. By default only logs errors. :type raise_on_error: bool :param list_only: When set to ``True``, only lists containers, but does not actually remove them. :type list_only: bool :return: List of removed containers. :rtype: list[unicode | str] """

        exclude_names = set(exclude or ())

        def _stopped_containers():
            for container in self.containers(all=True):
                c_names = [name[1:] for name in container['Names'] or () if name.find('/', 2)]
                c_status = container['Status']
                if (((include_initial and c_status == '') or c_status.startswith('Exited') or c_status == 'Dead') and
                        exclude_names.isdisjoint(c_names)):
                    c_id = container['Id']
                    c_name = primary_container_name(c_names, default=c_id, strip_trailing_slash=False)
                    yield c_id, c_name

        stopped_containers = list(_stopped_containers())
        if list_only:
            return stopped_containers
        removed_containers = []
        for cid, cn in stopped_containers:
            try:
                self.remove_container(cn)
            except:
                exc_info = sys.exc_info()
                if raise_on_error:
                    raise PartialResultsError(exc_info, removed_containers)
            else:
                removed_containers.append(cn)
        return removed_containers