def METHOD_NAME(self, trainer: Trainer, pl_module: LightningModule) -> None:
    # Trainer calls `on_validation_end` for sanity check. Therefore, it is necessary to avoid
    # calling `trial.report` multiple times at epoch 0. For more details, see
    # https://github.com/PyTorchLightning/pytorch-lightning/issues/1391.
    if trainer.sanity_checking:
        return
    current_score = trainer.callback_metrics.get(self.monitor)
    if current_score is None:
        message = (
            f"The metric '{self.monitor}' is not in the evaluation logs for pruning. "
            "Please make sure you set the correct metric name."
        )
        warnings.warn(message)
        return
    epoch = pl_module.current_epoch
    should_stop = False
    # Determine if the trial should be terminated in a single process.
    if not self.is_ddp_backend:
        self._trial.report(current_score.item(), step=epoch)
        if not self._trial.should_prune():
            return
        raise optuna.TrialPruned(f"Trial was pruned at epoch {epoch}.")
    # Determine if the trial should be terminated in a DDP.
    if trainer.is_global_zero:
        self._trial.report(current_score.item(), step=epoch)
        should_stop = self._trial.should_prune()
        # Update intermediate value in the storage.
        _trial_id = self._trial._trial_id
        _study = self._trial.study
        _trial_system_attrs = _study._storage.get_trial_system_attrs(_trial_id)
        intermediate_values = _trial_system_attrs.get(_INTERMEDIATE_VALUE)
        intermediate_values[epoch] = current_score.item()  # type: ignore[index]
        self._trial.storage.set_trial_system_attr(
            self._trial._trial_id, _INTERMEDIATE_VALUE, intermediate_values
        )
    # Terminate every process if any world process decides to stop.
    should_stop = trainer.strategy.broadcast(should_stop)
    trainer.should_stop = trainer.should_stop or should_stop
    if not should_stop:
        return
    if trainer.is_global_zero:
        # Update system_attr from global zero process.
        self._trial.storage.set_trial_system_attr(self._trial._trial_id, _PRUNED_KEY, True)
        self._trial.storage.set_trial_system_attr(self._trial._trial_id, _EPOCH_KEY, epoch)