code: def split_and_convert_to_cpu_int4_weights(
      cls, model_path, safetensor_per_layer_path
  ):
      model = AutoModelForCausalLM.from_pretrained(
          model_path, use_safetensors=True
      )
      model = optimize_model(model)
  
      state_dict = model.state_dict()
      layer_names = (
          ["model.embed_tokens."]
          + [
              f"model.layers.{i}."
              for i in range(len(model.model.layers))
          ]
          + ["model.norm.", "lm_head."]
      )
      for layer_name in tqdm(layer_names):
          local_state_dict = {
              k: v.contiguous()
              for k, v in state_dict.items()
              if k.startswith(layer_name)
          }
          save_name = os.path.join(
              safetensor_per_layer_path, f"{layer_name}safetensors"
          )
          save_file(local_state_dict, save_name)
      print(
          f"Save splitted safetensor weights to {safetensor_per_layer_path}"
      )
  
imports: import argparse
  import gc
  import os
  import time
  import warnings
  from typing import Dict, List, Optional, Union
  import torch
  import torch.nn
  from accelerate import init_empty_weights
  from safetensors.torch import load_file, save_file
  from tqdm.auto import tqdm
  from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
  from transformers.generation import GenerationMixin
  from transformers.modeling_outputs import CausalLMOutputWithPast
  from bigdl.llm import optimize_model
  from bigdl.llm.transformers.low_bit_linear import FP4Params, LowBitLinear
label_desc: Use image node_id 2 for calling the LowMemoryLlama obj's underlying member method code with example usage: obj.split_and_convert_to_cpu_int4_weights(cls, model_path, safetensor_per_layer_path) without return types