code: def detect_adapter_type(keys: List[str]) -> PeftType:
      # Detect type of adapter by keys
      # Inspired by this:
      # https://github.com/bmaltais/kohya_ss/blob/ed4e3b0239a40506de9a17e550e6cf2d0b867a4f/tools/lycoris_utils.py#L312
      for key in keys:
          if "alpha" in key:
              continue
          elif any(x in key for x in ["lora_down", "lora_up"]):
              # LoRA
              return PeftType.LORA
          elif any(
              x in key
              for x in ["hada_w1", "hada_w2", "hada_t1", "hada_t2"]
          ):
              # LoHa may have the following keys:
              # hada_w1_a, hada_w1_b, hada_w2_a, hada_w2_b, hada_t1, hada_t2
              return PeftType.LOHA
          elif any(
              x in key
              for x in ["lokr_w1", "lokr_w2", "lokr_t1", "lokr_t2"]
          ):
              # LoKr may have the following keys:
              # lokr_w1, lokr_w2, lokr_w1_a, lokr_w1_b, lokr_w2_a, lokr_w2_b, lokr_t1, lokr_t2
              return PeftType.LOKR
          elif "diff" in key:
              raise ValueError(
                  "Currently full diff adapters are not implemented"
              )
          else:
              raise ValueError(
                  "Unkown adapter type, probably not implemented"
              )
  
imports: import argparse
  import json
  import logging
  import os
  from collections import Counter
  from dataclasses import dataclass
  from operator import attrgetter
  from typing import Dict, List, Optional, Union
  import safetensors
  import torch
  import torch.nn
  from diffusers import UNet2DConditionModel
  from transformers import CLIPTextModel
  from peft import LoHaConfig, LoKrConfig, LoraConfig, PeftType, get_peft_model, set_peft_model_state_dict
  from peft.tuners.lokr.layer import factorization
label_desc: Use image node_id 5 for calling a global function with example usage: detect_adapter_type(keys) and returns: PeftType, PeftType, PeftType