class_docstr: PyTorch Lightning callback to prune unpromising trials.
  
  See `the example <https://github.com/optuna/optuna-examples/blob/
  main/pytorch/pytorch_lightning_simple.py>`__
  if you want to add a pruning callback which observes accuracy.
  
  Args:
      trial:
          A :class:`~optuna.trial.Trial` corresponding to the current evaluation of the
          objective function.
      monitor:
          An evaluation metric for pruning, e.g., ``val_loss`` or
          ``val_acc``. The metrics are obtained from the returned dictionaries from e.g.
          ``lightning.pytorch.LightningModule.training_step`` or
          ``lightning.pytorch.LightningModule.validation_epoch_end`` and the names thus depend on
          how this dictionary is formatted.
  
  
  .. note::
      For the distributed data parallel training, the version of PyTorchLightning needs to be
      higher than or equal to v1.6.0. In addition, :class:`~optuna.study.Study` should be
      instantiated with RDB storage.
  
  
  .. note::
      If you would like to use PyTorchLightningPruningCallback in a distributed training
      environment, you need to evoke `PyTorchLightningPruningCallback.check_pruned()`
      manually so that :class:`~optuna.exceptions.TrialPruned` is properly handled.
code: def on_fit_start(
      self, trainer: Trainer, pl_module: "pl.LightningModule"
  ) -> None:
      self.is_ddp_backend = (
          trainer._accelerator_connector.is_distributed
      )
      if self.is_ddp_backend:
          if version.parse(pl.__version__) < version.parse(  # type: ignore[attr-defined]
              "1.6.0"
          ):
              raise ValueError(
                  "PyTorch Lightning>=1.6.0 is required in DDP."
              )
          # If it were not for this block, fitting is started even if unsupported storage
          # is used. Note that the ValueError is transformed into ProcessRaisedException inside
          # torch.
          if not (
              isinstance(self._trial.study._storage, _CachedStorage)
              and isinstance(
                  self._trial.study._storage._backend, RDBStorage
              )
          ):
              raise ValueError(
                  "optuna.integration.PyTorchLightningPruningCallback"
                  " supports only optuna.storages.RDBStorage in DDP."
              )
          # It is necessary to store intermediate values directly in the backend storage because
          # they are not properly propagated to main process due to cached storage.
          # TODO(Shinichi) Remove intermediate_values from system_attr after PR #4431 is merged.
          if trainer.is_global_zero:
              self._trial.storage.set_trial_system_attr(
                  self._trial._trial_id,
                  _INTERMEDIATE_VALUE,
                  dict(),
              )
  
file_path: optuna/optuna/integration/pytorch_lightning.py
imports: import warnings
  from packaging import version
  import optuna
  from optuna.storages._cached_storage import _CachedStorage
  from optuna.storages._rdb.storage import RDBStorage
label_desc: Use image node_id 2 for calling the PyTorchLightningPruningCallback obj's underlying member method code with example usage: obj.on_fit_start(trainer, pl_module) without return types