<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def populate_sites( self, number_of_atoms, selected_sites=None ):
 """ Populate the lattice sites with a specific number of atoms. Args: number_of_atoms (Int):
 The number of atoms to populate the lattice sites with. selected_sites (:obj:List, optional):
 List of site labels if only some sites are to be occupied. Defaults to None. Returns: None """

        if number_of_atoms > self.number_of_sites:
            raise ValueError
        if selected_sites:
            atoms = [ atom.Atom( initial_site = site ) for site in random.sample( [ s for s in self.sites if s.label in selected_sites ], number_of_atoms ) ]
        else:
            atoms = [ atom.Atom( initial_site = site ) for site in random.sample( self.sites, number_of_atoms ) ]
        self.number_of_occupied_sites = number_of_atoms
        return atoms