<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def explode(self, hosts, hostgroups, contactgroups, servicegroups, servicedependencies):
 # pylint: disable=too-many-locals """ Explodes services, from host, hostgroups, contactgroups, servicegroups and dependencies. :param hosts: The hosts container :type hosts: [alignak.object.host.Host] :param hostgroups: The hosts goups container :type hostgroups: [alignak.object.hostgroup.Hostgroup] :param contactgroups: The contacts goups container :type contactgroups: [alignak.object.contactgroup.Contactgroup] :param servicegroups: The services goups container :type servicegroups: [alignak.object.servicegroup.Servicegroup] :param servicedependencies: The services dependencies container :type servicedependencies: [alignak.object.servicedependency.Servicedependency] :return: None """

        # Then for every service create a copy of the service with just the host
        # because we are adding services, we can't just loop in it
        itemkeys = list(self.items.keys())
        for s_id in itemkeys:
            serv = self.items[s_id]
            # items::explode_host_groups_into_hosts
            # take all hosts from our hostgroup_name into our host_name property
            self.explode_host_groups_into_hosts(serv, hosts, hostgroups)

            # items::explode_contact_groups_into_contacts
            # take all contacts from our contact_groups into our contact property
            self.explode_contact_groups_into_contacts(serv, contactgroups)

            hnames = getattr(serv, "host_name", '')
            hnames = list(set([n.strip() for n in hnames.split(',') if n.strip()]))
            # hnames = strip_and_uniq(hnames)
            # We will duplicate if we have multiple host_name
            # or if we are a template (so a clean service)
            if len(hnames) == 1:
                self.index_item(serv)
            else:
                if len(hnames) >= 2:
                    self.explode_services_from_hosts(hosts, serv, hnames)
                # Delete expanded source service, even if some errors exist
                self.remove_item(serv)

        for s_id in self.templates:
            template = self.templates[s_id]
            self.explode_contact_groups_into_contacts(template, contactgroups)
            self.explode_services_from_templates(hosts, template)

        # Explode services that have a duplicate_foreach clause
        duplicates = [serv.uuid for serv in self if getattr(serv, 'duplicate_foreach', '')]
        for s_id in duplicates:
            serv = self.items[s_id]
            self.explode_services_duplicates(hosts, serv)
            if not serv.configuration_errors:
                self.remove_item(serv)

        to_remove = []
        for service in self:
            host = hosts.find_by_name(service.host_name)
            if host and host.is_excluded_for(service):
                to_remove.append(service)
        for service in to_remove:
            self.remove_item(service)

        # Servicegroups property need to be fulfill for got the information
        # And then just register to this service_group
        for serv in self:
            self.register_service_into_servicegroups(serv, servicegroups)
            self.register_service_dependencies(serv, servicedependencies)