class_docstr: Precision plugin for training with Fully Sharded Data Parallel (FSDP).
  
  .. 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).
      scaler: An optional :class:`torch.distributed.fsdp.sharded_grad_scaler.ShardedGradScaler` to use.
  
  Raises:
      ValueError:
          If unsupported ``precision`` is provided.
class_docstr_tok: ["Precision","plugin","for","training","with","Fully","Sharded","Data","Parallel","(","FSDP",")",".","..","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",")",".","scaler",":","An","optional",":","class",":","`","torch.distributed.fsdp.sharded_grad_scaler.ShardedGradScaler","`","to","use",".","Raises",":","ValueError",":","If","unsupported","``","precision","``","is","provided","."]
code: def mixed_precision_config(self) -> "TorchMixedPrecision":
      from torch.distributed.fsdp.fully_sharded_data_parallel import (
          MixedPrecision as TorchMixedPrecision,
      )
  
      # With PyTorch < 2.0, FSDP uses the noneness of `param_dtype` as a proxy for the `_uses_param_mixed_precision`
      # property. In order to avoid FSDP assertion failures, we therefore avoid setting `param_dtype` to
      # `torch.float32` here with PyTorch < 2.0.
      if self.precision == "16-mixed":
          param_dtype = (
              None if not _TORCH_GREATER_EQUAL_2_0 else torch.float32
          )
          reduce_dtype = buffer_dtype = torch.float16
      elif self.precision == "bf16-mixed":
          param_dtype = (
              None if not _TORCH_GREATER_EQUAL_2_0 else torch.float32
          )
          reduce_dtype = buffer_dtype = torch.bfloat16
      elif self.precision == "16-true":
          param_dtype = reduce_dtype = buffer_dtype = torch.float16
      elif self.precision == "bf16-true":
          param_dtype = reduce_dtype = buffer_dtype = torch.bfloat16
      elif self.precision == "32-true":
          param_dtype = (
              None if not _TORCH_GREATER_EQUAL_2_0 else torch.float32
          )
          reduce_dtype = buffer_dtype = torch.float32
      else:
          raise ValueError(
              f"Was unable to infer precision type, received {self.precision!r}."
          )
  
      return TorchMixedPrecision(
          param_dtype=param_dtype,
          reduce_dtype=reduce_dtype,
          buffer_dtype=buffer_dtype,
      )
  
imports: from typing import TYPE_CHECKING, Any, ContextManager, Dict, Literal, Optional, cast
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor
  from torch.nn import Module
  from torch.optim import Optimizer
  from typing_extensions import get_args, override
  from lightning.fabric.plugins.precision.amp import _optimizer_handles_unscaling
  from lightning.fabric.plugins.precision.precision import Precision
  from lightning.fabric.plugins.precision.utils import _convert_fp_tensor, _DtypeContextManager
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_0
  from lightning.fabric.utilities.types import Optimizable
label_desc: Use image node_id 2 for calling the FSDPPrecision obj's underlying member method code with example usage: obj.mixed_precision_config() and returns: TorchMixedPrecision