class_docstr: Plugin for training with half precision.
  
  Args:
      precision: Whether to use ``torch.float16`` (``'16-true'``) or ``torch.bfloat16`` (``'bf16-true'``).
class_docstr_tok: ["Plugin","for","training","with","half","precision",".","Args",":","precision",":","Whether","to","use","``","torch.float16","``","(","``","'16-true","'","``",")","or","``","torch.bfloat16","``","(","``","'bf16-true","'","``",")","."]
docstr: A context manager to change the default tensor type when tensors get created during the module's forward.
  
  See: :meth:`torch.set_default_tensor_type`
docstr_tok: ["A","context","manager","to","change","the","default","tensor","type","when","tensors","get","created","during","the","module","'s","forward",".","See",":",":","meth",":","`","torch.set_default_tensor_type","`"]
code: def forward_context(self) -> Generator[None, None, None]:
      """A context manager to change the default tensor type when tensors get created during the module's forward.
  
      See: :meth:`torch.set_default_tensor_type`
  
      """
      default_dtype = torch.get_default_dtype()
      torch.set_default_dtype(self._desired_input_dtype)
      try:
          yield
      finally:
          torch.set_default_dtype(default_dtype)
  
file_path: pytorch-lightning/src/lightning/pytorch/plugins/precision/half.py
imports: from contextlib import contextmanager
  from typing import Any, ContextManager, Generator, Literal
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor
  from torch.nn import Module
  from typing_extensions import override
  from lightning.fabric.plugins.precision.utils import _convert_fp_tensor, _DtypeContextManager
  from lightning.pytorch.plugins.precision.precision import Precision
label_desc: Use image node_id 5 for calling the HalfPrecision obj's underlying member method code with example usage: obj.forward_context() without return types