class_docstr: A base layer for LyCORIS like adapters
class_docstr_tok: ["A","base","layer","for","LyCORIS","like","adapters"]
docstr: Merge the active adapter weights into the base weights
  
  Args:
      safe_merge (`bool`, *optional*):
          If `True`, the merge operation will be performed in a copy of the original weights and check for NaNs
          before merging the weights. This is useful if you want to check if the merge operation will produce
          NaNs. Defaults to `False`.
      adapter_names (`List[str]`, *optional*):
          The list of adapter names that should be merged. If `None`, all active adapters will be merged.
          Defaults to `None`.
docstr_tok: ["Merge","the","active","adapter","weights","into","the","base","weights","Args",":","safe_merge","(","`","bool","`",",","*","optional","*",")",":","If","`","True","`",",","the","merge","operation","will","be","performed","in","a","copy","of","the","original","weights","and","check","for","NaNs","before","merging","the","weights",".","This","is","useful","if","you","want","to","check","if","the","merge","operation","will","produce","NaNs",".","Defaults","to","`","False","`",".","adapter_names","(","`","List","[","str","]","`",",","*","optional","*",")",":","The","list","of","adapter","names","that","should","be","merged",".","If","`","None","`",",","all","active","adapters","will","be","merged",".","Defaults","to","`","None","`","."]
code: def merge(
      self,
      safe_merge: bool = False,
      adapter_names: Optional[List[str]] = None,
  ) -> None:
      """
      Merge the active adapter weights into the base weights
  
      Args:
          safe_merge (`bool`, *optional*):
              If `True`, the merge operation will be performed in a copy of the original weights and check for NaNs
              before merging the weights. This is useful if you want to check if the merge operation will produce
              NaNs. Defaults to `False`.
          adapter_names (`List[str]`, *optional*):
              The list of adapter names that should be merged. If `None`, all active adapters will be merged.
              Defaults to `None`.
      """
      if self.merged:
          warnings.warn(
              f"Already following adapters were merged {','.join(self.merged_adapters)}. "
              f"You are now additionally merging {','.join(self.active_adapters)}."
          )
      if adapter_names is None:
          adapter_names = self.active_adapters
  
      for active_adapter in adapter_names:
          if active_adapter in self._available_adapters:
              base_layer = self.get_base_layer()
  
              if safe_merge:
                  orig_weights = base_layer.weight.data
                  orig_weights += self.get_delta_weight(active_adapter)
  
                  if not torch.isfinite(orig_weights).all():
                      raise ValueError(
                          f"NaNs detected in the merged weights. The adapter {active_adapter} seems to be broken"
                      )
  
                  base_layer.weight.data = orig_weights
              else:
                  base_layer.weight.data += self.get_delta_weight(
                      active_adapter
                  )
              self.merged_adapters.append(active_adapter)
  
imports: from __future__ import annotations
  import warnings
  from abc import abstractmethod
  from dataclasses import dataclass, field
  from typing import Any, Dict, List, Optional, Set, Type, Union
  import torch
  import torch.nn
  from tqdm import tqdm
  from peft.config import PeftConfig
  from peft.utils import ModulesToSaveWrapper, _get_submodules
  from .tuners_utils import BaseTuner, BaseTunerLayer, check_target_module_exists
label_desc: Use image node_id 7 for calling the LycorisLayer obj's underlying member method code with example usage: obj.merge(safe_merge, adapter_names) without return types