class_docstr: Extending DDPSpawnStrategy to support launch subprocesses with optimized env variables.
docstr: Setup the distributed environment of sub processes, we add ipex optimization here.
code: def setup(self, trainer: "pl.Trainer") -> None:
      """Setup the distributed environment of sub processes, we add ipex optimization here."""
      invalidInputError(
          self.model is not None, "You must specify the model."
      )
  
      # when using spawn, multiple child processes may update the weights of
      # the same model, so we should copy the model to avoid it
      if self.strategy_name == "ddp_spawn":
          # in pl 1.6, a trainer holds a  a strategy holds a model, a model holds a trainer,
          # `trainer.model` equals to `trainer.strategy.model`, so after assigning to
          # `self.model`, the trainer's model will refer to new model automatically
          self.model = copy.deepcopy(self.model)
          # `copy.deepcopy(self.model)` can't copy `self.model.trainer` correctly sometimes,
          # so we reuse the original trainer
          self.model.trainer = trainer  # type: ignore
  
      super().setup(trainer)
  
      if trainer.training and self.auto_lr:
  
          def _unpack_lightning_optimizer(opt):
              return (
                  opt._optimizer
                  if isinstance(opt, LightningOptimizer)
                  else opt
              )
  
          optimizers = self.optimizers
          optimizers = [
              _unpack_lightning_optimizer(opt) for opt in optimizers
          ]
  
          for optimizer in optimizers:
              for param_group in optimizer.param_groups:
                  param_group["lr"] *= self.world_size
  
          lr_scheduler_configs = self.lr_scheduler_configs
          for config in lr_scheduler_configs:
              scheduler = config.scheduler
              if isinstance(scheduler, _LRScheduler):
                  scheduler.base_lrs = [  # type: ignore
                      lr * self.world_size for lr in scheduler.base_lrs  # type: ignore
                  ]
  
      if self.use_ipex:
          ipex_optimize(
              self.model,
              optimizers=self.optimizers,
              inplace=True,
              dtype=self.dtype,
          )
  
imports: import os
  import copy
  import multiprocessing
  from typing import Any, List, Optional, Callable
  import torch
  from torch import nn
  from torch.multiprocessing.spawn import ProcessContext
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.optim.lr_scheduler import _LRScheduler
  import pytorch_lightning
  from pytorch_lightning.trainer.states import TrainerFn
  from pytorch_lightning.core.optimizer import LightningOptimizer
  from pytorch_lightning.core.optimizer import _configure_schedulers_automatic_opt
  from pytorch_lightning.core.optimizer import _configure_schedulers_manual_opt
  from pytorch_lightning.core.optimizer import _set_scheduler_opt_idx, _validate_scheduler_api
  from pytorch_lightning.strategies.launchers import _SpawnLauncher
  from pytorch_lightning.strategies import DDPSpawnStrategy
  from pytorch_lightning.plugins.environments import LightningEnvironment
  from bigdl.nano.utils.common import schedule_processors
  from bigdl.nano.pytorch.dispatcher import _get_patch_status
  from bigdl.nano.deps.ipex.ipex_api import ipex_optimize
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.utils.common import EnvContext
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_12
  import logging
  import warnings
label_desc: Use image node_id 3 for calling the DDPSpawnStrategy obj's underlying member method code with example usage: obj.setup(trainer) and returns: unknown