code: def test_coirls(kernel, office_caltech_access):
      dataset = MultiDomainAdapDataset(office_caltech_access)
      dataset.prepare_data_loaders()
      dataloader = dataset.get_domain_loaders(
          split="train", batch_size=100
      )
      feature_network = ResNet18Feature()
      x, y, z = next(iter(dataloader))
      tgt_idx = torch.where(z == 0)
      src_idx = torch.where(z != 0)
  
      x_feat = feature_network(x)
      z_one_hot = one_hot(z)
      clf = CoIRLS(kernel=kernel, alpha=1.0)
  
      x_train = torch.cat((x_feat[src_idx], x_feat[tgt_idx]))
      y_train = y[src_idx]
      z_train = torch.cat((z_one_hot[src_idx], z_one_hot[tgt_idx]))
      clf.fit(x_train, y_train, z_train)
      y_pred = clf.predict(x_feat[tgt_idx])
  
      acc = accuracy_score(y[tgt_idx], y_pred)
  
      assert 0 <= acc <= 1
  
      if kernel == "linear":
          scores = [
              clf.decision_function(x_feat[src_idx])[:, 0],
              clf.decision_function(x_feat[tgt_idx])[:, 0],
          ]
          domain_labels = ["source", "target"]
          title = "Decision score distribution"
          title_kwargs = {"fontsize": 14, "fontweight": "bold"}
          hist_kwargs = {"alpha": 0.7}
          fig = distplot_1d(
              scores,
              labels=domain_labels,
              xlabel="Decision Scores",
              ylabel="Count",
              title=title,
              title_kwargs=title_kwargs,
              hist_kwargs=hist_kwargs,
          )
          assert isinstance(fig, matplotlib.figure.Figure)
  
file_path: pykale/tests/pipeline/test_multi_domain_adapter.py
imports: import matplotlib.figure
  import pytest
  import torch
  from sklearn.metrics import accuracy_score
  from torch.nn.functional import one_hot
  from kale.embed.image_cnn import ResNet18Feature
  from kale.interpret.visualize import distplot_1d
  from kale.loaddata.image_access import ImageAccess
  from kale.loaddata.multi_domain import MultiDomainAdapDataset
  from kale.pipeline.multi_domain_adapter import CoIRLS, create_ms_adapt_trainer
  from kale.predict.class_domain_nets import ClassNetSmallImage
  from tests.helpers.pipe_test_helper import ModelTestHelper
label_desc: Use image node_id 4 for calling a global function with example usage: test_coirls(kernel, office_caltech_access) without return types