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 __init__(self, precision: _PRECISION_INPUT) -> None:
      supported_precision = get_args(_PRECISION_INPUT)
      if precision not in supported_precision:
          raise ValueError(
              f"`Trainer(strategy='deepspeed', precision={precision!r})` is not supported."
              f" `precision` must be one of: {supported_precision}."
          )
      self.precision = precision
      precision_to_type = {
          "bf16-mixed": torch.bfloat16,
          "16-mixed": torch.float16,
          "bf16-true": torch.bfloat16,
          "16-true": torch.float16,
          "32-true": torch.float32,
      }
      self._desired_dtype = precision_to_type[self.precision]
  
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 1 to create a new DeepSpeedPrecision object from inherited base classes: Precision with example: obj = DeepSpeedPrecision(precision)