<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def magnetic_species_and_magmoms(self):
 """ Returns a dict of magnetic species and the magnitude of their associated magmoms. Will return a set if there are multiple magmoms per species. :return: dict of magnetic species and magmoms """


        structure = self.get_ferromagnetic_structure()

        magtypes = {
            str(site.specie): set()
            for site in structure
            if site.properties["magmom"] != 0
        }

        for site in structure:
            if site.properties["magmom"] != 0:
                magtypes[str(site.specie)].add(site.properties["magmom"])

        for sp, magmoms in magtypes.items():
            if len(magmoms) == 1:
                magtypes[sp] = magmoms.pop()
            else:
                magtypes[sp] = sorted(list(magmoms))

        return magtypes