class_docstr: Extending DDPSpawnStrategy to support launch subprocesses with optimized env variables.
docstr: Create a DDPSpawnStrategy, adding a cpu_for_each_process parameter.
code: def __init__(
      self,
      num_processes: int = 1,
      cpu_for_each_process: Optional[List[List[int]]] = None,
      use_ipex=False,
      dtype=None,
      auto_lr=False,
      **kwargs: Any,
  ):
      """Create a DDPSpawnStrategy, adding a cpu_for_each_process parameter."""
      device = "cpu"
      parallel_devices = [
          torch.device(device) for _ in range(num_processes)
      ]
      cluster_environment = LightningEnvironment()
  
      if (
          use_ipex
          and dtype == torch.bfloat16
          and "precision_plugin" not in kwargs
      ):
          from bigdl.nano.pytorch.strategies import IPEXBF16Precision
  
          super().__init__(
              parallel_devices=parallel_devices,
              cluster_environment=cluster_environment,
              precision_plugin=IPEXBF16Precision(),
              **kwargs,
          )
      else:
          super().__init__(
              parallel_devices=parallel_devices,
              cluster_environment=cluster_environment,
              **kwargs,
          )
      self.cpu_for_each_process = cpu_for_each_process
      self.is_distributed = True
      self.use_ipex = use_ipex
      self.dtype = dtype
      self.auto_lr = auto_lr
  
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 1 to create a new DDPSpawnStrategy object from inherited base classes: _DDPSpawnStrategy with example: obj = DDPSpawnStrategy(num_processes, cpu_for_each_process, use_ipex, dtype, auto_lr)