code: def __init__(
      self, net: network.Network, weights: network.NetworkWeights
  ):
      super().__init__(net, weights)
  
      self.lin_module = None
      self.org_module: list[torch.Module] = [self.sd_module]
  
      self.scale = 1.0
  
      # kohya-ss
      if "oft_blocks" in weights.w.keys():
          self.is_kohya = True
          self.oft_blocks = weights.w[
              "oft_blocks"
          ]  # (num_blocks, block_size, block_size)
          self.alpha = weights.w["alpha"]  # alpha is constraint
          self.dim = self.oft_blocks.shape[0]  # lora dim
      # LyCORIS
      elif "oft_diag" in weights.w.keys():
          self.is_kohya = False
          self.oft_blocks = weights.w["oft_diag"]
          # self.alpha is unused
          self.dim = self.oft_blocks.shape[
              1
          ]  # (num_blocks, block_size, block_size)
  
      is_linear = type(self.sd_module) in [
          torch.nn.Linear,
          torch.nn.modules.linear.NonDynamicallyQuantizableLinear,
      ]
      is_conv = type(self.sd_module) in [torch.nn.Conv2d]
      is_other_linear = type(self.sd_module) in [
          torch.nn.MultiheadAttention
      ]  # unsupported
  
      if is_linear:
          self.out_dim = self.sd_module.out_features
      elif is_conv:
          self.out_dim = self.sd_module.out_channels
      elif is_other_linear:
          self.out_dim = self.sd_module.embed_dim
  
      if self.is_kohya:
          self.constraint = self.alpha * self.out_dim
          self.num_blocks = self.dim
          self.block_size = self.out_dim // self.dim
      else:
          self.constraint = None
          self.block_size, self.num_blocks = factorization(
              self.out_dim, self.dim
          )
  
file_path: stable-diffusion-webui/extensions-builtin/Lora/network_oft.py
imports: import torch
  import network
  from lyco_helpers import factorization
  from einops import rearrange
label_desc: Use image node_id 1 to create a new NetworkModuleOFT object from inherited base classes: network with example: obj = NetworkModuleOFT(net, weights)