code: def filter_params(
      module: nn.Module, bn: bool = True, only_trainable=False
  ) -> Generator:
      """Yields the trainable parameters of a given module.
  
      Args:
          module: A given module
          bn: If False, don't return batch norm layers
  
      Returns:
          Generator
      """
      children = list(module.children())
      if not children:
          if not isinstance(module, BN_TYPES) or bn:
              for param in module.parameters():
                  if not only_trainable or param.requires_grad:
                      yield param
      else:
          for child in children:
              for param in filter_params(
                  module=child, bn=bn, only_trainable=only_trainable
              ):
                  yield param
  
file_path: icevision/icevision/models/utils.py
imports: from icevision.imports import *
  from icevision.utils import *
  from icevision.core import *
  from icevision.data import *
  from icevision.parsers import *
  from icevision.data.dataset import Dataset
label_desc: Use image node_id 1 for calling a global function with example usage: filter_params(module, bn, only_trainable) without return types