code: def add_casts_around_norms(model: nn.Module):
      """
      Function to put additional to/from float32 casts around operations known to require full precision.
      It was used with an extra post-parse script to have TRT preserve extra precision when --fp16 needed.
      Should not be needed with TRT 8.6.1 or later.
      """
      default_cast_replacements = {
          "BatchNorm1d": wrap_module(nn.BatchNorm1d, CastToFloat),
          "BatchNorm2d": wrap_module(nn.BatchNorm2d, CastToFloat),
          "LayerNorm": wrap_module(nn.LayerNorm, CastToFloat),
          "InstanceNorm1d": wrap_module(nn.InstanceNorm1d, CastToFloat),
          "MaskedInstanceNorm1d": wrap_module(
              MaskedInstanceNorm1d, CastToFloatAll
          ),
      }
      replace_modules(model, default_cast_replacements)
  
imports: import os
  from contextlib import nullcontext
  from enum import Enum
  from typing import Callable, Dict, Optional, Type
  import onnx
  import torch
  import torch.nn
  import torch.nn.functional
  from nemo.utils import CastToFloat, CastToFloatAll, logging
label_desc: Use image node_id 18 for calling a global function with example usage: add_casts_around_norms(model) without return types