code: def register_forward_hooks(self, model):
      for regularizer in self.regularizers:
          for module_name, module in model.named_modules():
              if fnmatch(
                  module_name, regularizer.module_filter
              ) and hasattr(module, "weight"):
                  hook = module.register_forward_hook(regularizer)
                  self._forward_hooks.append(hook)
  
      if len(self._forward_hooks) == 0:
          raise Exception(
              "Tried to register regularizers but no modules "
              "were found that matched any module_filter argument."
          )
  
imports: import torch
  from fnmatch import fnmatch
  from .callbacks import Callback
label_desc: Use image node_id 2 for calling the RegularizerContainer obj's underlying member method code with example usage: obj.register_forward_hooks(model) without return types