code: def test_pytorch_lightning_pruning_callback() -> None:
      def objective(trial: optuna.trial.Trial) -> float:
          callback = PyTorchLightningPruningCallback(
              trial, monitor="accuracy"
          )
          trainer = pl.Trainer(
              max_epochs=2,
              accelerator="cpu",
              enable_checkpointing=False,
              callbacks=[callback],
          )
  
          model = Model()
          trainer.fit(model)
  
          return 1.0
  
      study = optuna.create_study(pruner=DeterministicPruner(True))
      study.optimize(objective, n_trials=1)
      assert study.trials[0].state == optuna.trial.TrialState.PRUNED
  
      study = optuna.create_study(pruner=DeterministicPruner(False))
      study.optimize(objective, n_trials=1)
      assert study.trials[0].state == optuna.trial.TrialState.COMPLETE
      assert study.trials[0].value == 1.0
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import numpy
  import pytest
  import optuna
  from optuna._imports import try_import
  from optuna.integration import PyTorchLightningPruningCallback
  from optuna.testing.pruners import DeterministicPruner
  from optuna.testing.storages import StorageSupplier
label_desc: Use image node_id 1 for calling a global function with example usage: test_pytorch_lightning_pruning_callback() and returns: int