<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def side_chain_centres(assembly, masses=False):
 """ PseudoGroup containing side_chain centres of each Residue in each Polypeptide in Assembly. Notes ----- Each PseudoAtom is a side-chain centre. There is one PseudoMonomer per chain in ampal (each containing len(chain) PseudoAtoms). The PseudoGroup has len(ampal) PseudoMonomers. Parameters assembly : Assembly masses : bool If True, side-chain centres are centres of mass. If False, side-chain centres are centres of coordinates. Returns ------- PseudoGroup containing all side_chain centres, and with ampal_parent=assembly. """

    if masses:
        elts = set([x.element for x in assembly.get_atoms()])
        masses_dict = {e: element_data[e]['atomic mass'] for e in elts}
    pseudo_monomers = []
    for chain in assembly:
        if isinstance(chain, Polypeptide):
            centres = OrderedDict()
            for r in chain.get_monomers(ligands=False):
                side_chain = r.side_chain
                if masses:
                    masses_list = [masses_dict[x.element] for x in side_chain]
                else:
                    masses_list = None
                if side_chain:
                    centre = centre_of_mass(points=[x._vector for x in side_chain], masses=masses_list)
                # for Glycine residues.
                else:
                    centre = r['CA']._vector
                centres[r.unique_id] = PseudoAtom(coordinates=centre, name=r.unique_id, ampal_parent=r)
            pseudo_monomers.append(PseudoMonomer(pseudo_atoms=centres, monomer_id=' ', ampal_parent=chain))
    return PseudoGroup(monomers=pseudo_monomers, ampal_parent=assembly)