code: def load_gguf_llama(
      loader: GGUFFileLoader,
      dtype: torch.dtype = torch.float,
      low_bit="sym_int4",
  ):
      config = loader.config
  
      llama_config = LlamaConfig(
          vocab_size=len(config["tokenizer.ggml.tokens"]),
          hidden_size=config["llama.embedding_length"],
          intermediate_size=config["llama.feed_forward_length"],
          num_hidden_layers=config["llama.block_count"],
          num_attention_heads=config["llama.attention.head_count"],
          num_key_value_heads=config["llama.attention.head_count_kv"],
          hidden_act="silu",
          max_position_embeddings=config["llama.context_length"],
          rms_norm_eps=config["llama.attention.layer_norm_rms_epsilon"],
          use_cache=True,
          pad_token_id=None,
          bos_token_id=config["tokenizer.ggml.bos_token_id"],
          eos_token_id=config["tokenizer.ggml.eos_token_id"],
          pretraining_tp=1,
      )
  
      qtype = ggml_tensor_qtype[low_bit]
      n_head = config["llama.attention.head_count"]
      n_head_kv = config["llama.attention.head_count_kv"]
  
      with init_empty_weights():
          model = LlamaForCausalLM(llama_config)
  
      def process_llama(name, tensor):
          nonlocal model
          module_name = get_llama_module_name(name)
          if "q_proj" in module_name:
              # gguf weight needs to reshape for q_proj
              head, hd_size = tensor.shape[0], tensor.shape[1:]
              set_module_tensor_to_device(
                  model,
                  module_name,
                  "cpu",
                  tensor.reshape(
                      n_head, head // n_head // 2, 2, *hd_size
                  )
                  .swapaxes(1, 2)
                  .reshape(tensor.shape),
                  dtype=dtype,
              )
          elif "k_proj" in module_name:
              # gguf weight needs to reshape for k_proj
              head, hd_size = tensor.shape[0], tensor.shape[1:]
              set_module_tensor_to_device(
                  model,
                  module_name,
                  "cpu",
                  tensor.reshape(
                      n_head_kv, head // n_head_kv // 2, 2, *hd_size
                  )
                  .swapaxes(1, 2)
                  .reshape(tensor.shape),
                  dtype=dtype,
              )
          else:
              set_module_tensor_to_device(
                  model, module_name, "cpu", tensor, dtype=dtype
              )
          model = replace_with_low_bit_linear_for_module(
              model, qtype=qtype, module_name=module_name
          )
  
      tensor_loader = loader.tensor_loader
      tensor_loader.load_while_process(process_llama)
  
      # see https://github.com/google/sentencepiece/blob/master/src/sentencepiece_model.proto
      from transformers.convert_slow_tokenizer import import_protobuf
  
      spm_pb2 = import_protobuf("Failed to import protobuf")
  
      pieces = loader.tokenizer_pieces()
      trainer_spec = spm_pb2.TrainerSpec(
          byte_fallback=True,
          model_type=spm_pb2.TrainerSpec.ModelType.BPE,
      )
      proto = spm_pb2.ModelProto(
          pieces=pieces, trainer_spec=trainer_spec
      )
      proto = proto.SerializeToString()
  
      with NamedTemporaryFile(delete=False) as f:
          f.write(proto)
          f.close()
          tokenizer = LlamaTokenizer(f.name)
          os.remove(f.name)
  
      return model, tokenizer
  
file_path: BigDL/python/llm/src/bigdl/llm/transformers/gguf/models/llama.py
imports: import os
  import torch
  from accelerate import init_empty_weights
  from accelerate.utils import set_module_tensor_to_device
  from tempfile import NamedTemporaryFile
  from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer
  from ..gguf import GGUFFileLoader
  from bigdl.llm.ggml.quantize import ggml_tensor_qtype
  from bigdl.llm.transformers.convert import replace_with_low_bit_linear_for_module
label_desc: Use image node_id 1 for calling a global function with example usage: load_gguf_llama(loader, dtype, low_bit) and returns: model,  tokenizer