docstr: This method unmerges all merged adapter layers from the base weights.
docstr_tok: ["This","method","unmerges","all","merged","adapter","layers","from","the","base","weights","."]
code: def unmerge(self) -> None:
      """
      This method unmerges all merged adapter layers from the base weights.
      """
      if not self.merged:
          warnings.warn("Already unmerged. Nothing to do.")
          return
      while len(self.merged_adapters) > 0:
          active_adapter = self.merged_adapters.pop()
          if active_adapter in self._available_adapters:
              base_layer = self.get_base_layer()
              new_weights = base_layer.weight.data
              if isinstance(base_layer, nn.Linear):
                  new_weights = torch.transpose(new_weights, 0, 1)
              elif isinstance(base_layer, nn.Conv2d):
                  new_weights = new_weights.view(
                      [
                          base_layer.out_channels,
                          base_layer.in_channels
                          * base_layer.kernel_size[0]
                          * base_layer.kernel_size[1],
                      ]
                  )
                  new_weights = torch.transpose(new_weights, 0, 1)
              delta_weight = self.get_delta_weight(active_adapter)
              if new_weights.shape[1] != delta_weight.shape[1]:
                  # when in channels is not divisible by r
                  delta_weight = delta_weight[
                      : new_weights.shape[1], : new_weights.shape[1]
                  ]
              delta_inv = torch.inverse(delta_weight)
              orig_weights = torch.mm(new_weights, delta_inv)
  
              if isinstance(base_layer, nn.Linear):
                  orig_weights = torch.transpose(orig_weights, 0, 1)
              elif isinstance(base_layer, nn.Conv2d):
                  orig_weights = torch.transpose(orig_weights, 0, 1)
                  orig_weights = orig_weights.reshape(
                      [
                          base_layer.out_channels,
                          base_layer.in_channels,
                          base_layer.kernel_size[0],
                          base_layer.kernel_size[1],
                      ]
                  )
              base_layer.weight.data = orig_weights
  
imports: import math
  import warnings
  from typing import Any, List, Optional, Set, Tuple
  import torch
  import torch.nn
  from peft.tuners.lycoris_utils import LycorisLayer
label_desc: Use image node_id 9 for calling the OFTLayer obj's underlying member method code with example usage: obj.unmerge() without return types