class_docstr: A container to hold the result returned by ``_ManualOptimization``.
  
  It is created from the output of :meth:`~lightning.pytorch.core.LightningModule.training_step`.
  
  Attributes:
      extra: Anything returned by the ``training_step``.
class_docstr_tok: ["A","container","to","hold","the","result","returned","by","``","_ManualOptimization","``",".","It","is","created","from","the","output","of",":","meth",":","`","~lightning.pytorch.core.LightningModule.training_step","`",".","Attributes",":","extra",":","Anything","returned","by","the","``","training_step","``","."]
code: def from_training_step_output(
      cls, training_step_output: STEP_OUTPUT
  ) -> "ManualResult":
      extra = {}
      if isinstance(training_step_output, dict):
          extra = training_step_output.copy()
      elif isinstance(training_step_output, Tensor):
          extra = {"loss": training_step_output}
      elif training_step_output is not None:
          raise MisconfigurationException(
              "In manual optimization, `training_step` must either return a Tensor or have no return."
          )
  
      if "loss" in extra:
          # we detach manually as it's expected that it will have a `grad_fn`
          extra["loss"] = extra["loss"].detach()
  
      return cls(extra=extra)
  
imports: from collections import OrderedDict
  from contextlib import suppress
  from dataclasses import dataclass, field
  from typing import Any, Dict
  from torch import Tensor
  from typing_extensions import override
  import lightning.pytorch
  from lightning.pytorch.core.optimizer import do_nothing_closure
  from lightning.pytorch.loops import _Loop
  from lightning.pytorch.loops.optimization.closure import OutputResult
  from lightning.pytorch.loops.progress import _Progress, _ReadyCompletedTracker
  from lightning.pytorch.trainer import call
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.types import STEP_OUTPUT
label_desc: Use image node_id 1 for calling the ManualResult obj's underlying member method code with example usage: obj.from_training_step_output(cls, training_step_output) and returns: cls