class_docstr: Precision plugin for DeepSpeed integration.
  
  .. warning::  This is an :ref:`experimental <versioning:Experimental API>` feature.
  
  Args:
      precision: Full precision (32-true), half precision (16-true, bf16-true) or
          mixed precision (16-mixed, bf16-mixed).
  
  Raises:
      ValueError:
          If unsupported ``precision`` is provided.
class_docstr_tok: ["Precision","plugin","for","DeepSpeed","integration",".","..","warning",":",":","This","is","an",":","ref",":","`","experimental","<","versioning",":","Experimental","API",">","`","feature",".","Args",":","precision",":","Full","precision","(","32-true",")",",","half","precision","(","16-true",",","bf16-true",")","or","mixed","precision","(","16-mixed",",","bf16-mixed",")",".","Raises",":","ValueError",":","If","unsupported","``","precision","``","is","provided","."]
code: def optimizer_step(  # type: ignore[override]
      self,
      optimizer: Steppable,
      model: "pl.LightningModule",
      closure: Callable[[], Any],
      **kwargs: Any,
  ) -> Any:
      if isinstance(optimizer, LBFGS):
          raise MisconfigurationException(
              "DeepSpeed and the LBFGS optimizer are not compatible."
          )
      closure_result = closure()
      self._after_closure(model, optimizer)
      skipped_backward = closure_result is None
      # in manual optimization, the closure does not return a value
      if model.automatic_optimization and skipped_backward:
          raise MisconfigurationException(
              "Skipping backward by returning `None` from your `training_step` is not supported by `DeepSpeed`"
          )
      # DeepSpeed handles the optimizer step internally
      deepspeed_engine: "deepspeed.DeepSpeedEngine" = (
          model.trainer.model
      )
      return deepspeed_engine.step(**kwargs)
  
imports: from contextlib import nullcontext
  from typing import TYPE_CHECKING, Any, Callable, ContextManager, Optional, Union
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor
  from torch.nn import Module
  from torch.optim import LBFGS, Optimizer
  from typing_extensions import get_args, override
  import lightning.pytorch
  from lightning.fabric.plugins.precision.deepspeed import _PRECISION_INPUT
  from lightning.fabric.plugins.precision.utils import _convert_fp_tensor, _DtypeContextManager
  from lightning.fabric.utilities.types import Steppable
  from lightning.pytorch.plugins.precision.precision import Precision
  from lightning.pytorch.utilities import GradClipAlgorithmType
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from lightning.pytorch.utilities.rank_zero import WarningCache
label_desc: Use image node_id 7 for calling the DeepSpeedPrecision obj's underlying member method code with example usage: obj.optimizer_step(optimizer, model, closure) and returns: deepspeed_engine