code: def __init__(
      self,
      model: nn.Module,
      loss: Optional[nn.Module],
      cuda: bool = True,
      memory_format: torch.memory_format = torch.contiguous_format,
      amp: bool = False,
      scaler: Optional[torch.cuda.amp.GradScaler] = None,
      divide_loss: int = 1,
      ts_script: bool = False,
  ):
      assert not (
          amp and scaler is None
      ), "Gradient Scaler is needed for AMP"
  
      def xform(m: nn.Module) -> nn.Module:
          if cuda:
              m = m.cuda()
          m.to(memory_format=memory_format)
          return m
  
      self.model = xform(model)
      if ts_script:
          self.model = torch.jit.script(self.model)
      self.ts_script = ts_script
      self.loss = xform(loss) if loss is not None else None
      self.amp = amp
      self.scaler = scaler
      self.is_distributed = False
      self.divide_loss = divide_loss
      self._fwd_bwd = None
      self._forward = None
  
imports: import time
  from copy import deepcopy
  from functools import wraps
  from typing import Callable, Dict, Optional, Tuple
  import torch
  import torch.nn
  from torch.cuda.amp import autocast
  from torch.nn.parallel import DistributedDataParallel
  from .None import logger
  from .None import utils
  from .logger import TrainingMetrics, ValidationMetrics
  from .models.common import EMA
label_desc: Use image node_id 1 to create a new Executor object  with example: obj = Executor(model, loss, cuda, memory_format, amp, scaler, divide_loss, ts_script)