code: def fit_and_validate_dataset(
      dataset_name,
      fit_args,
      init_args=None,
      sample_size=1000,
      refit_full=True,
      delete_directory=True,
      extra_metrics=None,
      expected_model_count=2,
      path_as_absolute=False,
      compile=False,
      compiler_configs=None,
      allowed_dataset_features=None,
      expected_stacked_overfitting_at_test=None,
      expected_stacked_overfitting_at_val=None,
      scikit_api=False,
  ):
      if compiler_configs is None:
          compiler_configs = {}
      directory_prefix = "./datasets/"
      (
          train_data,
          test_data,
          dataset_info,
      ) = DatasetLoaderHelper.load_dataset(
          name=dataset_name, directory_prefix=directory_prefix
      )
      label = dataset_info["label"]
      _init_args = dict(
          label=label,
      )
      if allowed_dataset_features is not None:
          train_data = train_data[allowed_dataset_features + [label]]
          test_data = test_data[allowed_dataset_features + [label]]
  
      if init_args is None:
          init_args = _init_args
      else:
          init_args = copy.deepcopy(init_args)
          _init_args.update(init_args)
          init_args = _init_args
      if "path" not in init_args:
          init_args["path"] = os.path.join(
              directory_prefix,
              dataset_name,
              f"AutogluonOutput_{uuid.uuid4()}",
          )
      if path_as_absolute:
          init_args["path"] = PathConverter.to_absolute(
              path=init_args["path"]
          )
          assert PathConverter._is_absolute(path=init_args["path"])
      save_path = init_args["path"]
      predictor = FitHelper.fit_dataset(
          train_data=train_data,
          init_args=init_args,
          fit_args=fit_args,
          sample_size=sample_size,
          scikit_api=scikit_api,
      )
      if compile:
          predictor.compile(
              models="all", compiler_configs=compiler_configs
          )
          predictor.persist(models="all")
      if sample_size is not None and sample_size < len(test_data):
          test_data = test_data.sample(n=sample_size, random_state=0)
      predictor.predict(test_data)
      predictor.evaluate(test_data)
  
      if predictor.can_predict_proba:
          pred_proba = predictor.predict_proba(test_data)
          predictor.evaluate_predictions(
              y_true=test_data[label], y_pred=pred_proba
          )
      else:
          with pytest.raises(AssertionError):
              predictor.predict_proba(test_data)
  
      model_names = predictor.model_names()
      model_name = model_names[0]
      assert len(model_names) == expected_model_count
      if refit_full:
          refit_model_names = predictor.refit_full()
          assert len(refit_model_names) == expected_model_count
          refit_model_name = refit_model_names[model_name]
          assert "_FULL" in refit_model_name
          predictor.predict(test_data, model=refit_model_name)
          if predictor.can_predict_proba:
              predictor.predict_proba(test_data, model=refit_model_name)
      predictor.info()
      lb = predictor.leaderboard(
          test_data, extra_info=True, extra_metrics=extra_metrics
      )
      stacked_overfitting_assert(
          lb,
          predictor,
          expected_stacked_overfitting_at_val,
          expected_stacked_overfitting_at_test,
      )
  
      predictor_load = predictor.load(path=predictor.path)
      predictor_load.predict(test_data)
  
      assert os.path.realpath(save_path) == os.path.realpath(
          predictor.path
      )
      if delete_directory:
          shutil.rmtree(
              save_path, ignore_errors=True
          )  # Delete AutoGluon output directory to ensure runs' information has been removed.
      return predictor
  
imports: import copy
  import os
  import shutil
  import uuid
  from contextlib import contextmanager
  from typing import List, Tuple
  import numpy
  import pandas
  import pytest
  from autogluon.common.utils.path_converter import PathConverter
  from autogluon.common.utils.resource_utils import ResourceManager
  from autogluon.core.constants import BINARY, MULTICLASS, REGRESSION
  from autogluon.core.data.label_cleaner import LabelCleaner
  from autogluon.core.models import AbstractModel, BaggedEnsembleModel
  from autogluon.core.stacked_overfitting.utils import check_stacked_overfitting_from_leaderboard
  from autogluon.core.utils import download, generate_train_test_split, infer_problem_type, unzip
  from autogluon.features.generators import AbstractFeatureGenerator, AutoMLPipelineFeatureGenerator
  from autogluon.tabular import TabularDataset, TabularPredictor
label_desc: Use image node_id 1 for calling the FitHelper obj's underlying member method code with example usage: obj.fit_and_validate_dataset(dataset_name, fit_args, init_args, sample_size, refit_full, delete_directory, extra_metrics, expected_model_count, path_as_absolute, compile, compiler_configs, allowed_dataset_features, expected_stacked_overfitting_at_test, expected_stacked_overfitting_at_val, scikit_api) and returns: predictor