code: def recurse_remove_peft_layers(model):
      if is_torch_available():
          import torch
  
      r"""
      Recursively replace all instances of `LoraLayer` with corresponding new layers in `model`.
      """
      from peft.tuners.lora import LoraLayer
  
      for name, module in model.named_children():
          if len(list(module.children())) > 0:
              ## compound module, go inside it
              recurse_remove_peft_layers(module)
  
          module_replaced = False
  
          if isinstance(module, LoraLayer) and isinstance(
              module, torch.nn.Linear
          ):
              new_module = torch.nn.Linear(
                  module.in_features,
                  module.out_features,
                  bias=module.bias is not None,
              ).to(module.weight.device)
              new_module.weight = module.weight
              if module.bias is not None:
                  new_module.bias = module.bias
  
              module_replaced = True
          elif isinstance(module, LoraLayer) and isinstance(
              module, torch.nn.Conv2d
          ):
              new_module = torch.nn.Conv2d(
                  module.in_channels,
                  module.out_channels,
                  module.kernel_size,
                  module.stride,
                  module.padding,
                  module.dilation,
                  module.groups,
              ).to(module.weight.device)
  
              new_module.weight = module.weight
              if module.bias is not None:
                  new_module.bias = module.bias
  
              module_replaced = True
  
          if module_replaced:
              setattr(model, name, new_module)
              del module
  
              if torch.cuda.is_available():
                  torch.cuda.empty_cache()
  
      return model
  
file_path: llmga/llmga/diffusers/src/diffusers/utils/peft_utils.py
imports: import collections
  import importlib
  from packaging import version
  from .import_utils import is_peft_available, is_torch_available
label_desc: Use image node_id 1 for calling a global function with example usage: recurse_remove_peft_layers(model) and returns: model