code: def get_structure_with_only_magnetic_atoms(self, make_primitive=True):
          
  
          sites = [site for site in self.structure if abs(site.properties["magmom"]) > 0]
  
          structure = Structure.from_sites(sites)
  
          if make_primitive:
              structure = structure.get_primitive_structure(use_site_props=True)
  
          return structure
docs: Returns a Structure with only magnetic atoms present.
          :return: Structure