docstr: Initializes likelihood and module.
docstr_tok: ["Initializes","likelihood","and","module","."]
code: def initialize_module(self):
      """Initializes likelihood and module."""
      # pylint: disable=attribute-defined-outside-init
  
      # We need a custom implementation here because the module is initialized
      # with likelihood as an argument, which would not be passed otherwise.
      # We cannot use self.initialized_instance, since we need to know if
      # likelihood was actually (re-)initialized or not.
      likelihood = self.likelihood
      ll_kwargs = self.get_params_for("likelihood")
  
      module = self.module
      module_kwargs = self.get_params_for("module")
  
      initialized_ll = isinstance(likelihood, torch.nn.Module)
      initialized_module = isinstance(module, torch.nn.Module)
      initialized_both = initialized_ll and initialized_module
  
      if initialized_ll and not ll_kwargs:
          # likelihood already initialized and no params changed
          self.likelihood_ = likelihood
      else:
          # likelihood needs to be initialized because it's not yet or because
          # its arguments changed
          if initialized_ll:
              likelihood = type(likelihood)
          self.likelihood_ = likelihood(**ll_kwargs)
  
      # ExactGP requires likelihood to be passed
      if "likelihood" not in module_kwargs:
          module_kwargs["likelihood"] = self.likelihood_
  
      if initialized_both and not module_kwargs:
          # module and likelihood were already initialized no no params changed
          self.module_ = module
      else:
          # module needs to be initialized because it's not yet or because
          # the likelihood and/or its arguments changed
          if initialized_module:
              module = type(module)
          self.module_ = module(**module_kwargs)
  
      if not isinstance(self.module_, gpytorch.models.ExactGP):
          raise TypeError(
              "{} requires 'module' to be a gpytorch.models.ExactGP.".format(
                  self.__class__.__name__
              )
          )
      return self
  
imports: import pickle
  import re
  import gpytorch
  import numpy
  import torch
  from skorch.net import NeuralNet
  from skorch.dataset import ValidSplit
  from skorch.dataset import unpack_data
  from skorch.callbacks import EpochScoring
  from skorch.callbacks import EpochTimer
  from skorch.callbacks import PassthroughScoring
  from skorch.callbacks import PrintLog
  from skorch.utils import check_is_fitted
  from skorch.utils import get_dim
  from skorch.utils import is_dataset
  from skorch.utils import to_numpy
  from skorch.utils import to_tensor
label_desc: Use image node_id 2 for calling the ExactGPRegressor obj's underlying member method code with example usage: obj.initialize_module() and returns: self