code: def is_model_cfg_valid(model_cfg, level=1, problem_type=None):
      is_valid = True
      for key in model_cfg.get(AG_ARGS, {}):
          if key not in VALID_AG_ARGS_KEYS:
              logger.warning(f"WARNING: Unknown ag_args key: {key}")
      if AG_ARGS not in model_cfg:
          is_valid = False  # AG_ARGS is required
      elif model_cfg[AG_ARGS].get("model_type", None) is None:
          is_valid = False  # model_type is required
      elif model_cfg[AG_ARGS].get(
          "hyperparameter_tune_kwargs", None
      ) and model_cfg[AG_ARGS].get("disable_in_hpo", False):
          is_valid = False
      elif (
          not model_cfg[AG_ARGS].get("valid_stacker", True)
          and level > 1
      ):
          is_valid = False  # Not valid as a stacker model
      elif (
          not model_cfg[AG_ARGS].get("valid_base", True) and level == 1
      ):
          is_valid = False  # Not valid as a base model
      elif problem_type is not None and problem_type not in model_cfg[
          AG_ARGS
      ].get("problem_types", [problem_type]):
          is_valid = False  # Not valid for this problem_type
      return is_valid
  
file_path: autogluon/tabular/src/autogluon/tabular/trainer/model_presets/presets.py
imports: import copy
  import inspect
  import logging
  from collections import defaultdict
  from autogluon.common.model_filter import ModelFilter
  from autogluon.core.constants import AG_ARGS, AG_ARGS_ENSEMBLE, AG_ARGS_FIT, BINARY, MULTICLASS, QUANTILE, REGRESSION, SOFTCLASS
  from autogluon.core.models import AbstractModel, DummyModel, GreedyWeightedEnsembleModel, SimpleWeightedEnsembleModel, StackerEnsembleModel
  from autogluon.core.trainer.utils import process_hyperparameters
  from ...models import BoostedRulesModel, CatBoostModel, FastTextModel, FigsModel, FTTransformerModel, GreedyTreeModel, HSTreeModel, ImagePredictorModel, KNNModel, LGBModel, LinearModel, MultiModalPredictorModel, NNFastAiTabularModel, RFModel, RuleFitModel, TabPFNModel, TabularNeuralNetTorchModel, TextPredictorModel, VowpalWabbitModel, XGBoostModel, XTModel
  from ...models.tab_transformer.tab_transformer_model import TabTransformerModel
  from .presets_custom import get_preset_custom
label_desc: Use image node_id 3 for calling a global function with example usage: is_model_cfg_valid(model_cfg, level, problem_type) and returns: is_valid