class_docstr: Test class for first set of voting learner experiment tests.
docstr: Check given combination of training configuration options.
docstr_tok: ["Check","given","combination","of","training","configuration","options","."]
code: def check_train_task(self, learner_type, options_dict):
      """Check given combination of training configuration options."""
      # create a configuration file with the given options
      (
          config_path,
          estimator_names,
          job_name,
          custom_learner,
          objectives,
          _,
          model_kwargs_list,
          param_grid_list,
          sampler_list,
          _,
          _,
          _,
          _,
      ) = fill_in_config_options_for_voting_learners(
          learner_type, "train", options_dict
      )
  
      #  mock the `__init__()` method for the `VotingLearner` class so
      # that we can check that the voting learner was instantiated with
      # the right arguments; note that we are doing this mock separately
      # from all the others below since any `__init__`` patch needs to
      # return a `None` value which the other ones do not
      patcher = patch.object(
          VotingLearner, "__init__", return_value=None
      )
      mock_vl_init = patcher.start()
  
      # run the configuration file but with various methods/attributes for
      # `VotingLearner` mocked so that we can check that things were called
      # as expected without actually needing to train any models
      with patch.multiple(
          VotingLearner,
          train=DEFAULT,
          save=DEFAULT,
          model=DEFAULT,
          create=True,
      ) as mocks:
          run_configuration(config_path, quiet=True, local=True)
  
          # check that init was called the expected number of times;
          # if we are not doing grid search, everything is only called once
          # otherwise they are called as many times as there are objectives
          # (number of featuresets is 1)
          num_expected_calls = (
              len(objectives) if options_dict["with_grid_search"] else 1
          )
          self.assertEqual(mock_vl_init.call_count, num_expected_calls)
  
          # note that the init arguments are the same no matter the call
          expected_init_args = (estimator_names,)
          expected_init_kwargs = {
              "voting": "soft"
              if options_dict["with_soft_voting"]
              else "hard",
              "custom_learner_path": custom_learner,
              "feature_scaling": "with_mean"
              if options_dict["with_centering"]
              else "none",
              "pos_label": "dog"
              if options_dict["with_pos_label"]
              else None,
              "min_feature_count": 2
              if options_dict["with_min_feature_count"]
              else 1,
              "model_kwargs_list": model_kwargs_list,
              "sampler_list": sampler_list,
              "sampler_kwargs_list": None,
          }
  
          # check that each init call had the expected arguments
          for actual_call in mock_vl_init.call_args_list:
              self.assertEqual(actual_call[0], expected_init_args)
              for key, expected_value in expected_init_kwargs.items():
                  actual_value = actual_call[1][key]
                  self.assertEqual(actual_value, expected_value)
  
          # check that train was called the expected number of times
          self.assertEqual(
              mocks["train"].call_count, num_expected_calls
          )
  
          # check that each train call had the expected arguments
          expected_train_kwargs = {
              "param_grid_list": param_grid_list,
              "grid_search_folds": 4
              if options_dict["with_gs_folds"]
              else 5,
              "grid_search": options_dict["with_grid_search"],
              "grid_jobs": None,
              "shuffle": options_dict["with_shuffle"],
          }
  
          for idx, actual_call in enumerate(
              mocks["train"].call_args_list
          ):
              actual_arg = actual_call[0][0]
              self.assertTrue(isinstance(actual_arg, FeatureSet))
              self.assertEqual(set(actual_arg.labels), {"cat", "dog"})
              for key, expected_value in expected_train_kwargs.items():
                  actual_value = actual_call[1][key]
                  self.assertEqual(actual_value, expected_value)
  
              # if we aren't doing grid search, then the objective should be `None`
              self.assertEqual(
                  actual_call[1]["grid_objective"],
                  objectives[idx]
                  if options_dict["with_grid_search"]
                  else None,
              )
  
          # check that save was called the expected number of times
          self.assertEqual(mocks["save"].call_count, num_expected_calls)
  
          # check that each save call had the expected arguments
          for idx, actual_call in enumerate(
              mocks["save"].call_args_list
          ):
              if not options_dict["with_grid_search"] or (
                  options_dict["with_grid_search"]
                  and not options_dict["with_multiple_objectives"]
              ):
                  expected_save_args = (
                      output_dir / f"{job_name}.model",
                  )
              else:
                  expected_save_args = (
                      output_dir
                      / f"{job_name}_{objectives[idx]}.model",
                  )
              self.assertEqual(actual_call[0], expected_save_args)
  
      # stop all the manual patchers
      _ = patcher.stop()
  
file_path: skll/tests/test_voting_learners_expts_1.py
imports: import unittest
  from itertools import product
  from pathlib import Path
  from unittest.mock import DEFAULT, patch
  from skll.data import FeatureSet
  from skll.experiments import run_configuration
  from skll.learner.voting import VotingLearner
  from skll.utils.testing import BoolDict, config_dir, create_jsonlines_feature_files, fill_in_config_options_for_voting_learners, output_dir, remove_jsonlines_feature_files, train_dir
label_desc: Use image node_id 3 for calling the TestVotingLearnersExptsOne obj's underlying member method code with example usage: obj.check_train_task(learner_type, options_dict) without return types