code: def _replace_with_low_bit_linear(
      model,
      qtype,
      modules_to_not_convert=None,
      current_key_name=None,
      convert_shape_only=False,
      cpu_embedding=False,
  ):
      from bigdl.llm.transformers.low_bit_linear import (
          LowBitLinear,
          FP4Params,
          FP16Linear,
          BF16Linear,
      )
      from bigdl.llm.transformers.embedding import LLMEmbedding
  
      has_been_replaced = False
  
      for name, module in model.named_children():
          if current_key_name is None:
              current_key_name = []
  
          is_linear, linear_args = is_linear_module(module)
          if is_linear and name not in modules_to_not_convert:
              # Check if the current key is not in the `modules_to_not_convert`
              if not any(
                  key in ".".join(current_key_name)
                  for key in modules_to_not_convert
              ):
                  in_features, out_features, mp_group = linear_args
                  with init_empty_weights():
                      new_linear = None
                      is_gptq = is_auto_gptq_available() and isinstance(
                          module, QuantLinearCudaOld
                      )
                      is_awq = is_auto_awq_available() and isinstance(
                          module, WQLinear_GEMM
                      )
                      is_llm_awq = (
                          is_awq
                          and module.backend
                          == AwqBackendPackingMethod.LLMAWQ
                      )
                      if is_gptq or is_awq:
                          has_bias = (
                              module.bias is not None
                              and module.bias.abs().sum() != 0
                          )
                          new_linear = LowBitLinear(
                              in_features,
                              out_features,
                              qtype=qtype,
                              bias=has_bias,
                              mp_group=mp_group,
                          )
                          device = module.qweight.data.device
                          invalidInputError(
                              device.type != "meta",
                              "converting from meta device is not supported",
                          )
                          # Copy the weights
                          paramsLowBit = FP4Params(
                              data=convert_gptq(
                                  module, awq=is_awq, llm_awq=is_llm_awq
                              ),
                              requires_grad=False,
                              quantized=True,
                              _shape=(out_features, in_features),
                              convert_shape_only=convert_shape_only,
                              qtype=qtype,
                          ).to(device)
                          new_linear._parameters[
                              "weight"
                          ] = paramsLowBit
                          if has_bias:
                              new_linear._parameters[
                                  "bias"
                              ] = nn.Parameter(module.bias.data).to(
                                  device
                              )
                      elif qtype not in [
                          ggml_tensor_qtype["fp16"],
                          ggml_tensor_qtype["bf16"],
                      ]:
                          new_linear = LowBitLinear(
                              in_features,
                              out_features,
                              qtype,
                              module.bias is not None,
                              mp_group=mp_group,
                          )
  
                          device = module.weight.data.device
                          # Copy the weights
                          paramsLowBit = FP4Params(
                              data=module.weight.data,
                              requires_grad=False,
                              quantized=False,
                              _shape=None,
                              convert_shape_only=convert_shape_only,
                              qtype=qtype,
                          ).to(device)
                          new_linear._parameters[
                              "weight"
                          ] = paramsLowBit
                          if module.bias is not None:
                              new_linear._parameters[
                                  "bias"
                              ] = nn.Parameter(module.bias.data).to(
                                  device
                              )
                      elif qtype == ggml_tensor_qtype["fp16"]:
                          module.to(torch.float16)
                          new_linear = FP16Linear(
                              in_features,
                              out_features,
                              module.bias is not None,
                              mp_group=mp_group,
                          )
                          device = module.weight.data.device
                          from bigdl.llm.transformers.utils import (
                              get_ipex_version,
                          )
  
                          if get_ipex_version() < "2.1.10+xpu":
                              new_linear._parameters[
                                  "weight"
                              ] = nn.Parameter(module.weight)
                          else:
                              # only from 2.1, ipex provides matmul_bias_out
                              # so we need to transpose weight
                              new_weight = module.weight.transpose(
                                  0, 1
                              ).contiguous()
                              new_linear._parameters[
                                  "weight"
                              ] = nn.Parameter(new_weight)
                              new_linear.weight_type = 2
                          if module.bias is not None:
                              new_linear._parameters[
                                  "bias"
                              ] = nn.Parameter(module.bias.data).to(
                                  device
                              )
                      elif qtype == ggml_tensor_qtype["bf16"]:
                          module.to(torch.bfloat16)
                          new_linear = BF16Linear(
                              in_features,
                              out_features,
                              module.bias is not None,
                              mp_group=mp_group,
                          )
                          device = module.weight.data.device
                          # convert here
                          new_linear._parameters[
                              "weight"
                          ] = nn.Parameter(module.weight)
                          if module.bias is not None:
                              new_linear._parameters[
                                  "bias"
                              ] = nn.Parameter(module.bias.data).to(
                                  device
                              )
  
                      if new_linear is not None:
                          if not module.training:
                              new_linear.eval()
                          model._modules[name] = new_linear
                          has_been_replaced = True
                          # Force requires grad to False to avoid unexpected errors
                          model._modules[name].requires_grad_(False)
  
                          module.weight = None
          elif cpu_embedding and type(module) == nn.Embedding:
              # skip user-defined Embedding layer
              if platform.system().lower() == "windows":
                  model._modules[name] = LLMEmbedding(
                      num_embeddings=module.num_embeddings,
                      embedding_dim=module.embedding_dim,
                      padding_idx=module.padding_idx,
                      max_norm=module.max_norm,
                      norm_type=module.norm_type,
                      scale_grad_by_freq=module.scale_grad_by_freq,
                      sparse=module.sparse,
                      _weight=module.weight.data,
                  )
  
          # Remove the last key for recursion
          if len(list(module.children())) > 0:
              _, _flag = _replace_with_low_bit_linear(
                  module,
                  qtype,
                  modules_to_not_convert,
                  current_key_name,
                  convert_shape_only,
                  cpu_embedding,
              )
              has_been_replaced = _flag or has_been_replaced
      return model, has_been_replaced
  
imports: import platform
  import torch
  import torch.nn
  from accelerate import init_empty_weights
  import warnings
  import transformers
  import importlib.util
  from bigdl.llm.ggml.quantize import ggml_tensor_qtype
  from .utils import logger
  from typing import Union
  import numpy
  import os
  from bigdl.llm.utils.common import invalidInputError
label_desc: Use image node_id 6 for calling a global function with example usage: _replace_with_low_bit_linear(model, qtype, modules_to_not_convert, current_key_name, convert_shape_only, cpu_embedding) and returns: model,  has_been_replaced