class_docstr: A simple trainer for the most common type of task:
  single-cost single-optimizer single-data-source iterative optimization,
  optionally using data-parallelism.
  It assumes that every step, you:
  
  1. Compute the loss with a data from the data_loader.
  2. Compute the gradients with the above loss.
  3. Update the model with the optimizer.
  
  All other tasks during training (checkpointing, logging, evaluation, LR schedule)
  are maintained by hooks, which can be registered by :meth:`TrainerBase.register_hooks`.
  
  If you want to do anything fancier than this,
  either subclass TrainerBase and implement your own `run_step`,
  or write your own training loop.
class_docstr_tok: ["A","simple","trainer","for","the","most","common","type","of","task",":","single-cost","single-optimizer","single-data-source","iterative","optimization",",","optionally","using","data-parallelism",".","It","assumes","that","every","step",",","you",":","1",".","Compute","the","loss","with","a","data","from","the","data_loader",".","2",".","Compute","the","gradients","with","the","above","loss",".","3",".","Update","the","model","with","the","optimizer",".","All","other","tasks","during","training","(","checkpointing",",","logging",",","evaluation",",","LR","schedule",")","are","maintained","by","hooks",",","which","can","be","registered","by",":","meth",":","`","TrainerBase.register_hooks","`",".","If","you","want","to","do","anything","fancier","than","this",",","either","subclass","TrainerBase","and","implement","your","own","`","run_step","`",",","or","write","your","own","training","loop","."]
docstr: Implement the standard training logic described above.
docstr_tok: ["Implement","the","standard","training","logic","described","above","."]
code: def run_step(self):
      """
      Implement the standard training logic described above.
      """
      assert (
          self.model.training
      ), "[SimpleTrainer] model was changed to eval mode!"
      start = time.perf_counter()
      """
          If you want to do something with the data, you can wrap the dataloader.
          """
      data = next(self._data_loader_iter)
      data_time = time.perf_counter() - start
  
      if self.zero_grad_before_forward:
          """
          If you need to accumulate gradients or do something similar, you can
          wrap the optimizer with your custom `zero_grad()` method.
          """
          self.optimizer.zero_grad()
  
      """
          If you want to do something with the losses, you can wrap the model.
          """
      loss_dict = self.model(data)
      if isinstance(loss_dict, torch.Tensor):
          losses = loss_dict
          loss_dict = {"total_loss": loss_dict}
      else:
          losses = sum(loss_dict.values())
      if not self.zero_grad_before_forward:
          """
          If you need to accumulate gradients or do something similar, you can
          wrap the optimizer with your custom `zero_grad()` method.
          """
          self.optimizer.zero_grad()
      losses.backward()
  
      self.after_backward()
  
      if self.async_write_metrics:
          # write metrics asynchronically
          self.concurrent_executor.submit(
              self._write_metrics, loss_dict, data_time, iter=self.iter
          )
      else:
          self._write_metrics(loss_dict, data_time)
  
      """
          If you need gradient clipping/scaling or other processing, you can
          wrap the optimizer with your custom `step()` method. But it is
          suboptimal as explained in https://arxiv.org/abs/2006.15704 Sec 3.2.4
          """
      self.optimizer.step()
  
imports: import concurrent.futures
  import logging
  import numpy
  import time
  import weakref
  from typing import List, Mapping, Optional
  import torch
  from torch.nn.parallel import DataParallel, DistributedDataParallel
  import detectron2.utils.comm
  from detectron2.utils.events import EventStorage, get_event_storage
  from detectron2.utils.logger import _log_api_usage
label_desc: Use image node_id 2 for calling the SimpleTrainer obj's underlying member method code with example usage: obj.run_step() without return types