def METHOD_NAME(objective, n_trials):
    def decorator(trial):
        try:
            logging.info('starting trial %s / %s', trial.number, abs(n_trials-1))
            value = objective(trial)
            logging.info('finished trial %s / %s', trial.number, abs(n_trials-1))
            return value
        except optuna.exceptions.TrialPruned as exc:
            logging.info('pruned trial, trial number=%s', trial.number)
            raise exc
        except Exception as exc:
            message = 'failed trial, trial number=' + str(trial.number)
            logging.exception(message, exc_info=True)
            raise exc
    return decorator