code: def _convert_layers(module: torch.nn.Module) -> None:
      import transformer_engine.pytorch as te
  
      for name, child in module.named_children():
          if isinstance(child, torch.nn.Linear):
              if (
                  child.in_features % 8 != 0
                  or child.out_features % 16 != 0
              ):
                  # https://docs.nvidia.com/deeplearning/transformer-engine/user-guide/examples/fp8_primer.html#FP8-autocasting
                  rank_zero_warn(
                      "Support for FP8 in the linear layers with this plugin is currently limited to"
                      " tensors with shapes where the dimensions are divisible by 8 and 16 respectively."
                      f" The layer {name!r} does not fit this criteria. You might want to add padding to your inputs."
                  )
                  continue
              has_bias = child.bias is not None
              replacement = te.Linear(
                  child.in_features, child.out_features, bias=has_bias
              )
              replacement.weight.data = child.weight.data.clone()
              if has_bias:
                  replacement.bias.data = child.bias.data.clone()
              log.debug(
                  f"Replacing layer {name!r} with Transformer Engine equivalent"
              )
              module.__setattr__(name, replacement)
          elif isinstance(child, torch.nn.LayerNorm):
              replacement = te.LayerNorm(
                  child.normalized_shape[0], eps=child.eps
              )
              replacement.weight.data = child.weight.data.clone()
              replacement.bias.data = child.bias.data.clone()
              log.debug(
                  f"Replacing layer {name!r} with Transformer Engine equivalent"
              )
              module.__setattr__(name, replacement)
          else:
              # there are other transformer engine layers that we could convert but require fusion. full list at:
              # https://docs.nvidia.com/deeplearning/transformer-engine/user-guide/api/pytorch.html
              _convert_layers(child)
  
imports: import logging
  from contextlib import ExitStack
  from typing import TYPE_CHECKING, Any, ContextManager, Literal, Mapping, Optional, Union
  import torch
  from lightning_utilities import apply_to_collection
  from lightning_utilities.core.imports import RequirementCache
  from torch import Tensor
  from typing_extensions import override
  from lightning.fabric.plugins.precision.precision import Precision
  from lightning.fabric.plugins.precision.utils import _ClassReplacementContextManager, _convert_fp_tensor, _DtypeContextManager
  from lightning.fabric.utilities.rank_zero import rank_zero_info, rank_zero_warn
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_layers(module) without return types