def _load_model(
        self,
        low_bit_model: bool,
        load_in_4bit: bool,
        load_in_low_bit: str,
        model_name: str,
        model_kwargs: Any,
    ) -> Any:
        """Attempts to load a model with AutoModelForCausalLM and falls back to AutoModel on failure."""
        from ipex_llm.transformers import AutoModelForCausalLM, AutoModel

        load_kwargs = {"use_cache": True, "trust_remote_code": True}

        if not low_bit_model:
            if load_in_low_bit is not None:
                load_function_name = "from_pretrained"
                load_kwargs["load_in_low_bit"] = load_in_low_bit
            else:
                load_function_name = "from_pretrained"
                load_kwargs["load_in_4bit"] = load_in_4bit
        else:
            load_function_name = "load_low_bit"

        try:
            # Attempt to load with AutoModelForCausalLM
            return self._load_model_general(
                AutoModelForCausalLM,
                load_function_name,
                model_name,
                load_kwargs,
                model_kwargs,
            )
        except Exception:
            # Fallback to AutoModel if there's an exception
            return self._load_model_general(
                AutoModel, load_function_name, model_name, load_kwargs, model_kwargs
            )
Attempts to load a model with AutoModelForCausalLM and falls back to AutoModel on failure.
llama-index-integrations/llms/llama-index-llms-ipex-llm/llama_index/llms/ipex_llm/base.py