class_docstr: Encapsulates all the validation logic required by Opacus.
  Also works as a namespace to hold registered validators and fixers.
code: def _replace_sub_module(
      cls,
      *,
      root: nn.Module,
      sub_module_name: str,
      new_sub_module: nn.Module,
  ) -> None:
      sub_module_path = sub_module_name.split(".")
      if (
          len(sub_module_path) == 1 and sub_module_path[0] == ""
      ):  # root is the only sub_module of root
          return new_sub_module
      else:  # replace root's descendant
          sub_module_parent = root
          for name in sub_module_path[
              :-1
          ]:  # descend down to sub_module
              sub_module_parent = sub_module_parent._modules[name]
          sub_module_parent._modules[
              sub_module_path[-1]
          ] = new_sub_module
      return root
  
file_path: opacus/opacus/validators/module_validator.py
imports: import logging
  from typing import List
  import torch.nn
  from opacus.utils.module_utils import clone_module, get_submodule, trainable_modules
  from opacus.validators.errors import IllegalModuleConfigurationError, UnsupportedModuleError
label_desc: Use image node_id 4 for calling the ModuleValidator obj's underlying member method code with example usage: obj._replace_sub_module(cls) and returns: root, new_sub_module