code: def replace_layers_in_module(
      module: nn.Module, mapping_fn: Callable, *args, **kwargs
  ) -> bool:
      """
      Recursively iterate over the children of a module and replace them according to `mapping_fn`.
  
      Returns:
          True if a layer has been changed.
      """
      changed = False
      for name, child in module.named_children():
          new_module: Optional[nn.Module] = mapping_fn(
              child, *args, **kwargs
          )
  
          if new_module is not None:
              changed = True
              new_module.train(mode=child.training)
              module.add_module(name, new_module)
  
          # recursively apply to child
          changed |= replace_layers_in_module(
              child, mapping_fn, *args, **kwargs
          )
      return changed
  
file_path: baal/baal/bayesian/common.py
imports: import copy
  import warnings
  from typing import Callable, Optional
  import torch
  from torch import nn
label_desc: Use image node_id 1 for calling a global function with example usage: replace_layers_in_module(module, mapping_fn) and returns: changed