class_docstr: Manages a PyTorch model for training.
class_docstr_tok: ["Manages","a","PyTorch","model","for","training","."]
code: def __init__(
      self,
      model_creator,
      optimizer_creator,
      size,
      cores_per_worker,
      cluster_info=None,
      loss_creator=None,
      metrics=None,
      scheduler_creator=None,
      config=None,
      state_dict=None,
      backend="torch-distributed",
      mode="fit",
      sync_stats=True,
      log_level=logging.INFO,
      model_dir=None,
      log_to_driver=True,
      driver_ip=None,
      driver_log_port=None,
      driver_tcp_store_port=None,
  ):
      super().__init__(
          model_creator=model_creator,
          optimizer_creator=optimizer_creator,
          loss_creator=loss_creator,
          metrics=metrics,
          scheduler_creator=scheduler_creator,
          config=config,
          sync_stats=sync_stats,
          log_level=log_level,
      )
  
      self.state_dict = state_dict
      self.size = size
      self.mode = mode
      self.backend = backend
      self.model_dir = model_dir
      self.log_to_driver = log_to_driver
  
      self.setup(cores_per_worker)
      if self.log_to_driver:
          (
              self.log_path,
              self.logger_thread,
              self.thread_stop,
          ) = PytorchPysparkWorker._start_log_monitor(
              driver_ip, driver_log_port
          )
      if self.backend == "torch-distributed":
          self.setup_distributed(
              self.mode, cluster_info, driver_ip, driver_tcp_store_port
          )
  
file_path: BigDL/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_worker.py
imports: from bigdl.orca.learn.pytorch.torch_runner import TorchRunner
  import torch.distributed
  import logging
  import os
  import tempfile
  import copy
  from pyspark import BarrierTaskContext, TaskContext
  from bigdl.orca.learn.utils import save_pkl, duplicate_stdout_stderr_to_file, get_rank, get_partition_id
  from bigdl.orca.learn.log_monitor import LogMonitor
label_desc: Use image node_id 1 to create a new PytorchPysparkWorker object from inherited base classes: TorchRunner with example: obj = PytorchPysparkWorker(model_creator, optimizer_creator, size, cores_per_worker, cluster_info, loss_creator, metrics, scheduler_creator, config, state_dict, backend, mode, sync_stats, log_level, model_dir, log_to_driver, driver_ip, driver_log_port, driver_tcp_store_port)