class_docstr: Covariate-Independence Regularized Least Squares (CoIRLS)
  
  Args:
      kernel (str, optional): {"linear", "rbf", "poly"}. Kernel to use. Defaults to "linear".
      kernel_kwargs (dict or None, optional): Hyperparameter for the kernel. Defaults to None.
      alpha (float, optional): Hyperparameter of the l2 (Ridge) penalty. Defaults to 1.0.
      lambda_ (float, optional): Hyperparameter of the covariate dependence.  Defaults to 1.0.
  
  Reference:
      [1] Zhou, S., 2022. Interpretable Domain-Aware Learning for Neuroimage Classification (Doctoral dissertation,
          University of Sheffield).
      [2] Zhou, S., Li, W., Cox, C.R., & Lu, H. (2020). Side Information Dependence as a Regularizer for Analyzing
          Human Brain Conditions across Cognitive Experiments. AAAI 2020, New York, USA.
docstr: fit a model with input data, labels and covariates
  
  Args:
      x (np.ndarray or tensor): shape (n_samples, n_features)
      y (np.ndarray or tensor): shape (n_samples, )
      covariates (np.ndarray or tensor): (n_samples, n_covariates)
docstr_tok: ["fit","a","model","with","input","data",",","labels","and","covariates","Args",":","x","(","np.ndarray","or","tensor",")",":","shape","(","n_samples",",","n_features",")","y","(","np.ndarray","or","tensor",")",":","shape","(","n_samples",",",")","covariates","(","np.ndarray","or","tensor",")",":","(","n_samples",",","n_covariates",")"]
code: def fit(self, x, y, covariates):
      """fit a model with input data, labels and covariates
  
      Args:
          x (np.ndarray or tensor): shape (n_samples, n_features)
          y (np.ndarray or tensor): shape (n_samples, )
          covariates (np.ndarray or tensor): (n_samples, n_covariates)
      """
      self._label_binarizer.fit(y)
      x = torch.as_tensor(x)
      x = torch.cat([x, torch.ones(x.shape[0], 1)], 1)
      y = torch.as_tensor(y)
      krnl_x = torch.as_tensor(
          pairwise_kernels(
              x.detach().numpy(),
              metric=self.kernel,
              filter_params=True,
              **self.kernel_kwargs,
          ),
          dtype=torch.float,
      )
      n_samples = x.shape[0]
      n_classes = torch.unique(y).shape[0]
      n_labeled = y.shape[0]
      unit_mat = torch.eye(n_samples)
      ctr_mat = unit_mat - 1.0 / n_samples * torch.ones(
          (n_samples, n_samples)
      )
      mat_j = torch.zeros((n_samples, n_samples))
      mat_j[:n_labeled, :n_labeled] = torch.eye(n_labeled)
  
      covariates = torch.as_tensor(covariates, dtype=torch.float)
      krnl_cov = torch.mm(covariates, covariates.T)
  
      if n_classes == 2:
          mat_y = torch.zeros((n_samples, 1))
      else:
          mat_y = torch.zeros((n_samples, n_classes))
      mat_y[:n_labeled, :] = torch.as_tensor(
          self._label_binarizer.fit_transform(y)
      )
      mat_y = torch.as_tensor(mat_y)
  
      mat_q = torch.mm(mat_j, krnl_x) + self.alpha * unit_mat
      mat_q += self.lambda_ * multi_dot(
          (ctr_mat, krnl_cov, ctr_mat, krnl_x)
      )
  
      self.coef_ = torch.linalg.solve(mat_q, mat_y)
  
      self.x = x
  
imports: import torch
  import torch.nn
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.metrics.pairwise import pairwise_kernels
  from sklearn.preprocessing import LabelBinarizer
  from torch.linalg import multi_dot
  from torch.nn.functional import one_hot
  import kale.predict.losses
  from kale.embed.image_cnn import _Bottleneck
  from kale.pipeline.domain_adapter import BaseAdaptTrainer
label_desc: Use image node_id 2 for calling the CoIRLS obj's underlying member method code with example usage: obj.fit(x, y, covariates) without return types