code: def replace_modules(
      parent: torch.nn.Module,
      name: str,
      new_module: torch.nn.Module,
      strict_match: bool = True,
      match_device: bool = True,
  ) -> list[tuple[str, torch.nn.Module]]:
      """
      Replace sub-module(s) in a parent module.
  
      The name of the module to be replace can be nested e.g.,
      `features.denseblock1.denselayer1.layers.relu1`. If this is the case (there are "."
      in the module name), then this function will recursively call itself.
  
      Args:
          parent: module that contains the module to be replaced
          name: name of module to be replaced. Can include ".".
          new_module: `torch.nn.Module` to be placed at position `name` inside `parent`. This will
              be deep copied if `strict_match == False` multiple instances are independent.
          strict_match: if `True`, module name must `== name`. If false then
              `name in named_modules()` will be used. `True` can be used to change just
              one module, whereas `False` can be used to replace all modules with similar
              name (e.g., `relu`).
          match_device: if `True`, the device of the new module will match the model. Requires all
              of `parent` to be on the same device.
  
      Returns:
          List of tuples of replaced modules. Element 0 is module name, element 1 is the replaced module.
  
      Raises:
          AttributeError: if `strict_match` is `True` and `name` is not a named module in `parent`.
      """
      out: list[tuple[str, torch.nn.Module]] = []
      _replace_modules(
          parent, name, new_module, out, strict_match, match_device
      )
      return out
  
imports: from __future__ import annotations
  import io
  import re
  import warnings
  from collections import OrderedDict
  from collections.abc import Callable, Mapping, Sequence
  from contextlib import contextmanager
  from copy import deepcopy
  from typing import Any
  import numpy
  import torch
  import torch.nn
  from monai.apps.utils import get_logger
  from monai.config import PathLike
  from monai.utils.misc import ensure_tuple, save_obj, set_determinism
  from monai.utils.module import look_up_option, optional_import, pytorch_after
  from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor
label_desc: Use image node_id 23 for calling a global function with example usage: replace_modules(parent, name, new_module, strict_match, match_device) and returns: out