class_docstr: Encapsulates all the validation logic required by Opacus.
  Also works as a namespace to hold registered validators and fixers.
docstr: Make the module and sub_modules DP compatible by running registered custom fixers.
  
  Args:
      module: The root module to be made compatible.
      **kwargs: Arbitrary keyword arguments.
  
  Returns:
      Fixed module.
docstr_tok: ["Make","the","module","and","sub_modules","DP","compatible","by","running","registered","custom","fixers",".","Args",":","module",":","The","root","module","to","be","made","compatible",".","*","*","kwargs",":","Arbitrary","keyword","arguments",".","Returns",":","Fixed","module","."]
code: def fix(cls, module: nn.Module, **kwargs) -> nn.Module:
      """
      Make the module and sub_modules DP compatible by running registered custom fixers.
  
      Args:
          module: The root module to be made compatible.
          **kwargs: Arbitrary keyword arguments.
  
      Returns:
          Fixed module.
      """
      module = clone_module(module)
      # iterate over all sub_modules
      # We have to get sub_module names in a list first as we will be
      # changing the modules inside the loop.
      sub_module_names = [name for name, _ in trainable_modules(module)]
      for sub_module_name in sub_module_names:
          # get sub_module
          sub_module = get_submodule(module, sub_module_name)
          # if sub_module has a registered fixer
          if type(sub_module) in ModuleValidator.FIXERS:
              # get a replacement for sub_module
              sub_module_fixer = ModuleValidator.FIXERS[
                  type(sub_module)
              ]
              new_sub_module = sub_module_fixer(sub_module, **kwargs)
              # move new_sub_module to the same device as that of sub_module
              new_sub_module.to(next(sub_module.parameters()).device)
              # get module after replacement.
              module = cls._replace_sub_module(
                  root=module,
                  sub_module_name=sub_module_name,
                  new_sub_module=new_sub_module,
              )
              # log it
              logger.info(
                  f"Replaced sub_module {sub_module_name} : {sub_module}"
                  f" with {new_sub_module}"
              )
      # return fixed module
      return module
  
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 3 for calling the ModuleValidator obj's underlying member method code with example usage: obj.fix(cls, module) and returns: module