code: def named_modules(net):
      """For a skorch net, yield all module names and modules
  
      Ignore modules that are not ``torch.nn.Module`` instances.
  
      """
      # pylint: disable=protected-access
      for module_name in net._modules + net._criteria:
          module = getattr(net, module_name + "_")
          if isinstance(module, torch.nn.Module):
              yield module_name, module
  
imports: from collections.abc import Mapping
  from functools import partial
  import numpy
  from sklearn.exceptions import NotFittedError
  from sklearn.utils.validation import check_is_fitted
  import torch
  from skorch.exceptions import NotInitializedError
  from skorch.utils import to_numpy
label_desc: Use image node_id 1 for calling a global function with example usage: named_modules(net) without return types