code: def test_ddp_wrapper(tmpdir, precision):
      """Test parameters to ignore are carried over for DDP."""
  
      class WeirdModule(torch.nn.Module):
          def _save_to_state_dict(self, destination, prefix, keep_vars):
              return {"something": "something"}
  
      class CustomModel(BoringModel):
          def __init__(self):
              super().__init__()
              self.weird_module = WeirdModule()
  
              # should be skipped
              self._ddp_params_and_buffers_to_ignore = ["something"]
  
      class CustomCallback(Callback):
          def on_train_start(
              self,
              trainer: "pl.Trainer",
              pl_module: "pl.LightningModule",
          ) -> None:
              assert isinstance(
                  trainer.strategy.model, DistributedDataParallel
              )
              expected = ["something"]
              assert (
                  trainer.strategy.model.parameters_to_ignore
                  == set(expected)
                  if _TORCH_GREATER_EQUAL_2_0
                  else expected
              )
              assert (
                  trainer.strategy.model.module._ddp_params_and_buffers_to_ignore
                  == expected
              )
  
      model = CustomModel()
      trainer = Trainer(
          default_root_dir=tmpdir,
          fast_dev_run=True,
          precision=precision,
          strategy="ddp",
          accelerator="gpu",
          devices=2,
          callbacks=CustomCallback(),
          enable_progress_bar=False,
          enable_model_summary=False,
      )
      trainer.fit(model)
  
imports: import os
  from unittest import mock
  from unittest.mock import Mock
  import lightning.pytorch
  import pytest
  import torch
  from lightning.fabric.plugins.environments import ClusterEnvironment, LightningEnvironment
  from lightning.fabric.utilities.distributed import _distributed_is_initialized
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_0
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import Callback, EarlyStopping
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
  from lightning.pytorch.strategies import DDPStrategy
  from lightning.pytorch.strategies.launchers import _SubprocessScriptLauncher
  from lightning.pytorch.strategies.launchers.multiprocessing import _MultiProcessingLauncher
  from lightning.pytorch.trainer import seed_everything
  from torch.distributed.optim import ZeroRedundancyOptimizer
  from torch.multiprocessing import ProcessRaisedException
  from torch.nn.parallel.distributed import DistributedDataParallel
  import tests_pytorch.helpers.pipelines
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
label_desc: Use image node_id 5 for calling a global function with example usage: test_ddp_wrapper(tmpdir, precision) and returns: dict