code: def check_model_config(
      cfg: DictDefault, model_config: Union[AutoConfig, DictDefault]
  ):
      quant_config_exists = (
          hasattr(model_config, "quantization_config")
          and model_config.quantization_config
      )
      quant_config_method_is_gptq = (
          quant_config_exists
          and "quant_method" in model_config.quantization_config
          and model_config.quantization_config["quant_method"] == "gptq"
      )
  
      if cfg.gptq and not quant_config_method_is_gptq:
          raise ValueError(
              "model_config.quantization_config is not set or quant_method is not set to gptq. "
              "Please make sure to point to a GPTQ model."
          )
  
      if not cfg.gptq and quant_config_exists:
          raise ValueError(
              "model_config.quantization_config is set but `gptq` flag is not. "
              "Please use the `gptq` flag to train quantized model or point to a non-quantized model."
          )
  
      lora_modules_to_save = get_linear_embedding_layers(
          model_config.model_type
      )
      if (
          cfg.adapter
          and cfg.tokens
          and (
              not cfg.lora_modules_to_save
              or not all(
                  x in cfg.lora_modules_to_save
                  for x in lora_modules_to_save
              )
          )
      ):
          lora_modules_to_save = ", ".join(
              map(lambda x: f"`{x}`", lora_modules_to_save)
          )
          raise ValueError(
              f"`lora_modules_to_save` not properly set when adding new tokens. Please include {lora_modules_to_save} in `lora_modules_to_save`."
          )
  
imports: import logging
  import math
  import os
  from typing import Any, Optional, Tuple, Union
  import addict
  import bitsandbytes
  import torch
  import transformers
  from optimum.bettertransformer import BetterTransformer
  from peft import PeftConfig, prepare_model_for_kbit_training
  from peft.tuners.lora import QuantLinear
  from transformers import AddedToken, AutoConfig, AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, GPTQConfig, PreTrainedModel, PreTrainedTokenizerBase
  from transformers.deepspeed import is_deepspeed_zero3_enabled
  from axolotl.models.mamba import fix_mamba_attn_for_loss
  from axolotl.prompt_tokenizers import LLAMA_DEFAULT_EOS_TOKEN
  from axolotl.utils.bench import log_gpu_memory_usage
  from axolotl.utils.chat_templates import chat_templates
  from axolotl.utils.dict import DictDefault
  from axolotl.utils.lora_embeddings import get_linear_embedding_layers
label_desc: Use image node_id 1 for calling a global function with example usage: check_model_config(cfg, model_config) without return types