<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_stage_for_epoch(self, epoch_start, name, attr='stage', save=True):
 """Change the stage for one specific epoch. Parameters epoch_start : int start time of the epoch, in seconds name : str description of the stage or qualifier. attr : str, optional either 'stage' or 'quality' save : bool whether to save every time one epoch is scored Raises ------ KeyError When the epoch_start is not in the list of epochs. IndexError When there is no rater / epochs at all Notes ----- In the GUI, you want to save as often as possible, even if it slows down the program, but it's the safer option. But if you're converting a dataset, you want to save at the end. Do not forget to save! """

        if self.rater is None:
            raise IndexError('You need to have at least one rater')

        for one_epoch in self.rater.iterfind('stages/epoch'):
            if int(one_epoch.find('epoch_start').text) == epoch_start:
                one_epoch.find(attr).text = name
                if save:
                    self.save()
                return

        raise KeyError('epoch starting at ' + str(epoch_start) + ' not found')