class_docstr: Tests based on a more non-standard model
  
  Specifically, add modules with non-standard names and non-standard outputs
  like tuples or dicts.
  
  This test class does not re-iterate all the tests performed on the standard
  model but focuses on the parts that change, e.g. how the outputs are
  recorded.
class_docstr_tok: ["Tests","based","on","a","more","non-standard","model","Specifically",",","add","modules","with","non-standard","names","and","non-standard","outputs","like","tuples","or","dicts",".","This","test","class","does","not","re-iterate","all","the","tests","performed","on","the","standard","model","but","focuses","on","the","parts","that","change",",","e.g",".","how","the","outputs","are","recorded","."]
docstr: Customize net to work with complex modules
docstr_tok: ["Customize","net","to","work","with","complex","modules"]
code: def net_cls(self, module2_cls):
      """Customize net to work with complex modules"""
      from skorch import NeuralNetClassifier
      from skorch.utils import to_tensor
  
      class MyNet(NeuralNetClassifier):
          """Customize net that works with non-standard modules"""
  
          def initialize_module(self):
              kwargs = self.get_params_for("mymodule")
              module = self.initialized_instance(module2_cls, kwargs)
              # pylint: disable=attribute-defined-outside-init
              self.mymodule_ = module
              self.seq_ = nn.Sequential(nn.Linear(2, 2))
  
              return self
  
          def initialize_criterion(self):
              # use non-standard name 'mycriterion'
              kwargs = self.get_params_for("mycriterion")
              criterion = self.initialized_instance(
                  self.criterion, kwargs
              )
              # pylint: disable=attribute-defined-outside-init
              self.mycriterion_ = criterion
              return self
  
          def infer(self, x, **fit_params):
              x = to_tensor(x, device=self.device)
              x = self.mymodule_(x, **fit_params)
              x = x + self.seq_(x)
              return x
  
          def get_loss(self, y_pred, y_true, *args, **kwargs):
              y_true = to_tensor(y_true, device=self.device)
              return self.mycriterion_(y_pred, y_true)
  
      return MyNet
  
imports: import itertools
  from unittest import mock
  import numpy
  import pytest
  import torch
  from torch import nn
label_desc: Use image node_id 5 for calling the TestSkorchDoctorComplexArchitecture obj's underlying member method code with example usage: obj.net_cls(module2_cls) and returns: MyNet, self, self, x, self