<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _aftermathmp(self):
 """Aftermath for multiprocessing."""

        if not self._flag_e and self._flag_m:
            # join processes
            [proc.join() for proc in self._mpprc]
            if self._exeng == 'server':
                self._mpsvc.join()

            # restore attributes
            if self._exeng == 'server':
                self._frame = list(self._mpfrm)
                self._reasm = list(self._mprsm)
                self._trace = copy.deepcopy(self._mpkit.trace)
            if self._exeng == 'pipeline':
                self._frame = [self._mpkit.frames[x] for x in sorted(self._mpkit.frames)]
                self._reasm = copy.deepcopy(self._mpkit.reassembly)
                self._trace = copy.deepcopy(self._mpkit.trace)

            # shutdown & cleanup
            self._mpmng.shutdown()
            [delattr(self, attr) for attr in filter(lambda s: s.startswith('_mp'), dir(self))]
            self._frnum -= 2