code: def replace_module(
      parent_module: torch.nn.Module,
      child_name: str,
      old_module: torch.nn.Module,
      new_module: torch.nn.Module,
  ):
      """Replace the target module with the new module."""
  
      device = old_module.weight.device
      setattr(parent_module, child_name, new_module)
  
      # copy weight and bias from the target module
      new_module.weight = old_module.weight
      if hasattr(old_module, "bias") and old_module.bias is not None:
          new_module.bias = old_module.bias
  
      # move the new_module to the same device as the old_module
      new_module.to(device)
  
imports: from typing import List
  import torch
  from typeguard import check_argument_types
label_desc: Use image node_id 5 for calling a global function with example usage: replace_module(parent_module, child_name, old_module, new_module) without return types