code: def test_merge_with_defaults_early_stop(
      use_train, use_hyperopt_scheduler
  ):
      all_input_features = [
          binary_feature(),
          category_feature(),
          number_feature(),
          text_feature(name="utterance"),
      ]
      all_output_features = [
          category_feature(output_feature=True),
          sequence_feature(output_feature=True),
          vector_feature(),
      ]
  
      # validate config with all features
      config = {
          INPUT_FEATURES: all_input_features,
          OUTPUT_FEATURES: all_output_features,
          HYPEROPT: HYPEROPT_CONFIG,
      }
      config = copy.deepcopy(config)
  
      if use_train:
          config[TRAINER] = {"batch_size": 42}
  
      if use_hyperopt_scheduler:
          # hyperopt scheduler cannot be used with early stopping
          config[HYPEROPT][EXECUTOR][SCHEDULER] = SCHEDULER_DICT
  
      merged_config = ModelConfig.from_dict(config).to_dict()
  
      # When a scheulder is provided, early stopping in the rendered config needs to be disabled to allow the
      # hyperopt scheduler to manage trial lifecycle.
      expected = (
          -1
          if use_hyperopt_scheduler
          else ECDTrainerConfig().early_stop
      )
      assert merged_config[TRAINER]["early_stop"] == expected
  
file_path: ludwig/tests/ludwig/utils/test_defaults.py
imports: import copy
  import pytest
  from ludwig.constants import CATEGORY, COMBINER, DECODER, DEFAULTS, DEPENDENCIES, DROP_ROW, EARLY_STOP, ENCODER, EXECUTOR, FILL_WITH_MODE, HYPEROPT, INPUT_FEATURES, LOSS, MISSING_VALUE_STRATEGY, MODEL_ECD, MODEL_TYPE, OUTPUT_FEATURES, PREPROCESSING, REDUCE_DEPENDENCIES, REDUCE_INPUT, SCHEDULER, SUM, TIED, TOP_K, TRAINER, TYPE
  from ludwig.schema.model_config import ModelConfig
  from ludwig.schema.trainer import ECDTrainerConfig
  from ludwig.utils.backward_compatibility import upgrade_config_dict_to_latest_version
  from ludwig.utils.misc_utils import merge_dict, set_default_values
  from tests.integration_tests.utils import binary_feature, category_feature, number_feature, sequence_feature, text_feature, vector_feature
label_desc: Use image node_id 1 for calling a global function with example usage: test_merge_with_defaults_early_stop(use_train, use_hyperopt_scheduler) without return types