code: def _replace_with_bnb_linear(
      model,
      modules_to_not_convert=None,
      current_key_name=None,
      quantization_config=None,
      has_been_replaced=False,
  ):
      """
      Private method that wraps the recursion for module replacement.
  
      Returns the converted model and a boolean that indicates if the conversion has been successfull or not.
      """
      for name, module in model.named_children():
          if current_key_name is None:
              current_key_name = []
          current_key_name.append(name)
  
          if (
              isinstance(module, nn.Linear)
              or isinstance(module, Conv1D)
          ) 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
              ):
                  with init_empty_weights():
                      if isinstance(module, Conv1D):
                          (
                              in_features,
                              out_features,
                          ) = module.weight.shape
                      else:
                          in_features = module.in_features
                          out_features = module.out_features
  
                      if (
                          quantization_config.quantization_method()
                          == "llm_int8"
                      ):
                          model._modules[name] = bnb.nn.Linear8bitLt(
                              in_features,
                              out_features,
                              module.bias is not None,
                              has_fp16_weights=quantization_config.llm_int8_has_fp16_weight,
                              threshold=quantization_config.llm_int8_threshold,
                          )
                          has_been_replaced = True
                      else:
                          if (
                              quantization_config.llm_int8_skip_modules
                              is not None
                              and name
                              in quantization_config.llm_int8_skip_modules
                          ):
                              pass
                          else:
                              model._modules[name] = bnb.nn.Linear4bit(
                                  in_features,
                                  out_features,
                                  module.bias is not None,
                                  quantization_config.bnb_4bit_compute_dtype,
                                  compress_statistics=quantization_config.bnb_4bit_use_double_quant,
                                  quant_type=quantization_config.bnb_4bit_quant_type,
                              )
                              has_been_replaced = True
                      # Store the module class in case we need to transpose the weight later
                      model._modules[name].source_cls = type(module)
                      # Force requires grad to False to avoid unexpected errors
                      model._modules[name].requires_grad_(False)
          if len(list(module.children())) > 0:
              _, has_been_replaced = _replace_with_bnb_linear(
                  module,
                  modules_to_not_convert,
                  current_key_name,
                  quantization_config,
                  has_been_replaced=has_been_replaced,
              )
          # Remove the last key for recursion
          current_key_name.pop(-1)
      return model, has_been_replaced
  
file_path: transformers/src/transformers/integrations/bitsandbytes.py
imports: import importlib.metadata
  import warnings
  from copy import deepcopy
  from packaging import version
  from ..utils import is_accelerate_available, is_bitsandbytes_available, logging
label_desc: Use image node_id 2 for calling a global function with example usage: _replace_with_bnb_linear(model, modules_to_not_convert, current_key_name, quantization_config, has_been_replaced) and returns: model,  has_been_replaced