code: def calc_updown(self, orig_weight):
      oft_blocks = self.oft_blocks.to(
          orig_weight.device, dtype=orig_weight.dtype
      )
      eye = torch.eye(self.block_size, device=self.oft_blocks.device)
  
      if self.is_kohya:
          block_Q = oft_blocks - oft_blocks.transpose(
              1, 2
          )  # ensure skew-symmetric orthogonal matrix
          norm_Q = torch.norm(block_Q.flatten())
          new_norm_Q = torch.clamp(norm_Q, max=self.constraint)
          block_Q = block_Q * ((new_norm_Q + 1e-8) / (norm_Q + 1e-8))
          oft_blocks = torch.matmul(
              eye + block_Q, (eye - block_Q).float().inverse()
          )
  
      R = oft_blocks.to(orig_weight.device, dtype=orig_weight.dtype)
  
      # This errors out for MultiheadAttention, might need to be handled up-stream
      merged_weight = rearrange(
          orig_weight,
          "(k n) ... -> k n ...",
          k=self.num_blocks,
          n=self.block_size,
      )
      merged_weight = torch.einsum(
          "k n m, k n ... -> k m ...", R, merged_weight
      )
      merged_weight = rearrange(merged_weight, "k m ... -> (k m) ...")
  
      updown = (
          merged_weight.to(orig_weight.device, dtype=orig_weight.dtype)
          - orig_weight
      )
      output_shape = orig_weight.shape
      return self.finalize_updown(updown, orig_weight, output_shape)
  
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 2 for calling the NetworkModuleOFT obj's underlying member method code with example usage: obj.calc_updown(orig_weight) and returns: self