class_docstr: Encapsulates all the validation logic required by Opacus.
  Also works as a namespace to hold registered validators and fixers.
docstr: Validate module and sub_modules by running registered custom validators.
  Returns or raises exceptions depending on ``strict`` flag.
  
  Args:
      module: The root module to validate.
      strict: Boolean to indicate whether to raise errors or return
      the list of errors.
  
  Raises:
      UnsupportedModuleError in case of validation failures.
docstr_tok: ["Validate","module","and","sub_modules","by","running","registered","custom","validators",".","Returns","or","raises","exceptions","depending","on","``","strict","``","flag",".","Args",":","module",":","The","root","module","to","validate",".","strict",":","Boolean","to","indicate","whether","to","raise","errors","or","return","the","list","of","errors",".","Raises",":","UnsupportedModuleError","in","case","of","validation","failures","."]
code: def validate(
      cls, module: nn.Module, *, strict: bool = False
  ) -> List[UnsupportedModuleError]:
      """
      Validate module and sub_modules by running registered custom validators.
      Returns or raises exceptions depending on ``strict`` flag.
  
      Args:
          module: The root module to validate.
          strict: Boolean to indicate whether to raise errors or return
          the list of errors.
  
      Raises:
          UnsupportedModuleError in case of validation failures.
      """
      errors = []
      # 1. validate that module is in training mode
      if not module.training:
          errors.append(
              IllegalModuleConfigurationError(
                  "Model needs to be in training mode"
              )
          )
      # 2. perform module specific validations for trainable modules.
      # TODO: use module name here - it's useful part of error message
      for _, sub_module in trainable_modules(module):
          if type(sub_module) in ModuleValidator.VALIDATORS:
              sub_module_validator = ModuleValidator.VALIDATORS[
                  type(sub_module)
              ]
              errors.extend(sub_module_validator(sub_module))
      # raise/return as needed
      if strict and len(errors) > 0:
          raise UnsupportedModuleError(errors)
      else:
          return errors
  
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 1 for calling the ModuleValidator obj's underlying member method code with example usage: obj.validate(cls, module) and returns: errors