code: def _replace_with_awq_layers(model, awq_config: AwqConfig):
      layers = get_blocks(model)
  
      for i in tqdm(range(len(layers)), desc="Replacing layers..."):
          layer = layers[i]
  
          # Get every linear layer in a block
          named_linears = get_named_linears(layer)
  
          # Replace activation functions
          scale_activations(layer)
  
          # Replace nn.Linear with WQLinear
          for name, module in named_linears.items():
              if any(
                  key in name
                  for key in awq_config.modules_to_not_convert
              ):
                  continue
              if awq_config.version == "gemm":
                  q_linear_module = WQLinear_GEMM
              elif awq_config.version == "gemv":
                  q_linear_module = WQLinear_GEMV
  
              q_linear = q_linear_module.from_linear(
                  module,
                  awq_config.bits,
                  awq_config.group_size,
                  awq_config.backend,
                  True,
              )
              q_linear.to(next(layer.parameters()).device)
              set_op_by_name(layer, name, q_linear)
  
          gc.collect()
  
file_path: BigDL/python/llm/src/bigdl/llm/transformers/awq/awq.py
imports: import gc
  import os
  from tqdm import tqdm
  import torch
  import torch.nn
  from transformers.models.bloom.modeling_bloom import BloomForCausalLM
  from transformers.models.opt.modeling_opt import OPTForCausalLM
  from transformers.models.llama.modeling_llama import LlamaForCausalLM
  from transformers.models.bloom.modeling_bloom import BloomBlock
  from transformers import AwqConfig, AutoConfig
  from bigdl.llm.transformers.awq.linear import WQLinear_GEMM, WQLinear_GEMV
  from huggingface_hub import snapshot_download
  from bigdl.llm.utils.common import invalidInputError
label_desc: Use image node_id 7 for calling a global function with example usage: _replace_with_awq_layers(model, awq_config) without return types