code: def test_domain_adaptor(
      da_method, n_fewshot, download_path, testing_cfg
  ):
      if n_fewshot is None:
          if da_method in ["FSDANN", "MME", "Source"]:
              return
      else:
          if da_method in [
              "DANN",
              "CDAN",
              "CDAN-E",
              "WDGRL",
              "WDGRLMod",
              "DAN",
              "JAN",
          ]:
              return
  
      source, target, num_channels = DigitDataset.get_source_target(
          DigitDataset(SOURCE), DigitDataset(TARGET), download_path
      )
      dataset = MultiDomainDatasets(
          source,
          target,
          config_weight_type=WEIGHT_TYPE,
          config_size_type=DATASIZE_TYPE,
          n_fewshot=n_fewshot,
      )
  
      # setup feature extractor
      feature_network = SmallCNNFeature(num_channels)
      # setup classifier
      feature_dim = feature_network.output_size()
      classifier_network = ClassNetSmallImage(feature_dim, NUM_CLASSES)
      train_params = testing_cfg["train_params"]
      method_params = {}
      da_method = domain_adapter.Method(da_method)
  
      if da_method.is_mmd_method():
          model = domain_adapter.create_mmd_based(
              method=da_method,
              dataset=dataset,
              feature_extractor=feature_network,
              task_classifier=classifier_network,
              **method_params,
              **train_params,
          )
      else:  # All other non-mmd DA methods are dann like with critic
          critic_input_size = feature_dim
          # setup critic network
          if da_method.is_cdan_method():
              critic_input_size = 1024
              method_params["use_random"] = True
  
          critic_network = DomainNetSmallImage(critic_input_size)
  
          # The following calls kale.loaddata.dataset_access for the first time
          model = domain_adapter.create_dann_like(
              method=da_method,
              dataset=dataset,
              feature_extractor=feature_network,
              task_classifier=classifier_network,
              critic=critic_network,
              **method_params,
              **train_params,
          )
  
      ModelTestHelper.test_model(model, train_params)
  
file_path: pykale/tests/pipeline/test_domain_adapter.py
imports: import pytest
  import kale.pipeline.domain_adapter
  from kale.embed.image_cnn import SmallCNNFeature
  from kale.loaddata.image_access import DigitDataset
  from kale.loaddata.multi_domain import MultiDomainDatasets
  from kale.predict.class_domain_nets import ClassNetSmallImage, DomainNetSmallImage
  from tests.helpers.pipe_test_helper import ModelTestHelper
label_desc: Use image node_id 2 for calling a global function with example usage: test_domain_adaptor(da_method, n_fewshot, download_path, testing_cfg) without return types