<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_trial_complete(self, trial_id, result=None, error=False, early_terminated=False):
 """Passes the result to BayesOpt unless early terminated or errored"""

        if result:
            self.optimizer.register(
                params=self._live_trial_mapping[trial_id],
                target=result[self._reward_attr])

        del self._live_trial_mapping[trial_id]