code: def convert_light_adapter(src_state):
      original_body_length = (
          max(
              [
                  int(x.split(".")[1])
                  for x in src_state.keys()
                  if "body." in x
              ]
          )
          + 1
      )
  
      assert original_body_length == 4
  
      res_state = {
          # body.0.in_conv
          "adapter.body.0.in_conv.weight": src_state.pop(
              "body.0.in_conv.weight"
          ),
          "adapter.body.0.in_conv.bias": src_state.pop(
              "body.0.in_conv.bias"
          ),
          # body.0.resnets.0
          "adapter.body.0.resnets.0.block1.weight": src_state.pop(
              "body.0.body.0.block1.weight"
          ),
          "adapter.body.0.resnets.0.block1.bias": src_state.pop(
              "body.0.body.0.block1.bias"
          ),
          "adapter.body.0.resnets.0.block2.weight": src_state.pop(
              "body.0.body.0.block2.weight"
          ),
          "adapter.body.0.resnets.0.block2.bias": src_state.pop(
              "body.0.body.0.block2.bias"
          ),
          # body.0.resnets.1
          "adapter.body.0.resnets.1.block1.weight": src_state.pop(
              "body.0.body.1.block1.weight"
          ),
          "adapter.body.0.resnets.1.block1.bias": src_state.pop(
              "body.0.body.1.block1.bias"
          ),
          "adapter.body.0.resnets.1.block2.weight": src_state.pop(
              "body.0.body.1.block2.weight"
          ),
          "adapter.body.0.resnets.1.block2.bias": src_state.pop(
              "body.0.body.1.block2.bias"
          ),
          # body.0.resnets.2
          "adapter.body.0.resnets.2.block1.weight": src_state.pop(
              "body.0.body.2.block1.weight"
          ),
          "adapter.body.0.resnets.2.block1.bias": src_state.pop(
              "body.0.body.2.block1.bias"
          ),
          "adapter.body.0.resnets.2.block2.weight": src_state.pop(
              "body.0.body.2.block2.weight"
          ),
          "adapter.body.0.resnets.2.block2.bias": src_state.pop(
              "body.0.body.2.block2.bias"
          ),
          # body.0.resnets.3
          "adapter.body.0.resnets.3.block1.weight": src_state.pop(
              "body.0.body.3.block1.weight"
          ),
          "adapter.body.0.resnets.3.block1.bias": src_state.pop(
              "body.0.body.3.block1.bias"
          ),
          "adapter.body.0.resnets.3.block2.weight": src_state.pop(
              "body.0.body.3.block2.weight"
          ),
          "adapter.body.0.resnets.3.block2.bias": src_state.pop(
              "body.0.body.3.block2.bias"
          ),
          # body.0.out_conv
          "adapter.body.0.out_conv.weight": src_state.pop(
              "body.0.out_conv.weight"
          ),
          "adapter.body.0.out_conv.bias": src_state.pop(
              "body.0.out_conv.bias"
          ),
          # body.1.in_conv
          "adapter.body.1.in_conv.weight": src_state.pop(
              "body.1.in_conv.weight"
          ),
          "adapter.body.1.in_conv.bias": src_state.pop(
              "body.1.in_conv.bias"
          ),
          # body.1.resnets.0
          "adapter.body.1.resnets.0.block1.weight": src_state.pop(
              "body.1.body.0.block1.weight"
          ),
          "adapter.body.1.resnets.0.block1.bias": src_state.pop(
              "body.1.body.0.block1.bias"
          ),
          "adapter.body.1.resnets.0.block2.weight": src_state.pop(
              "body.1.body.0.block2.weight"
          ),
          "adapter.body.1.resnets.0.block2.bias": src_state.pop(
              "body.1.body.0.block2.bias"
          ),
          # body.1.resnets.1
          "adapter.body.1.resnets.1.block1.weight": src_state.pop(
              "body.1.body.1.block1.weight"
          ),
          "adapter.body.1.resnets.1.block1.bias": src_state.pop(
              "body.1.body.1.block1.bias"
          ),
          "adapter.body.1.resnets.1.block2.weight": src_state.pop(
              "body.1.body.1.block2.weight"
          ),
          "adapter.body.1.resnets.1.block2.bias": src_state.pop(
              "body.1.body.1.block2.bias"
          ),
          # body.1.body.2
          "adapter.body.1.resnets.2.block1.weight": src_state.pop(
              "body.1.body.2.block1.weight"
          ),
          "adapter.body.1.resnets.2.block1.bias": src_state.pop(
              "body.1.body.2.block1.bias"
          ),
          "adapter.body.1.resnets.2.block2.weight": src_state.pop(
              "body.1.body.2.block2.weight"
          ),
          "adapter.body.1.resnets.2.block2.bias": src_state.pop(
              "body.1.body.2.block2.bias"
          ),
          # body.1.body.3
          "adapter.body.1.resnets.3.block1.weight": src_state.pop(
              "body.1.body.3.block1.weight"
          ),
          "adapter.body.1.resnets.3.block1.bias": src_state.pop(
              "body.1.body.3.block1.bias"
          ),
          "adapter.body.1.resnets.3.block2.weight": src_state.pop(
              "body.1.body.3.block2.weight"
          ),
          "adapter.body.1.resnets.3.block2.bias": src_state.pop(
              "body.1.body.3.block2.bias"
          ),
          # body.1.out_conv
          "adapter.body.1.out_conv.weight": src_state.pop(
              "body.1.out_conv.weight"
          ),
          "adapter.body.1.out_conv.bias": src_state.pop(
              "body.1.out_conv.bias"
          ),
          # body.2.in_conv
          "adapter.body.2.in_conv.weight": src_state.pop(
              "body.2.in_conv.weight"
          ),
          "adapter.body.2.in_conv.bias": src_state.pop(
              "body.2.in_conv.bias"
          ),
          # body.2.body.0
          "adapter.body.2.resnets.0.block1.weight": src_state.pop(
              "body.2.body.0.block1.weight"
          ),
          "adapter.body.2.resnets.0.block1.bias": src_state.pop(
              "body.2.body.0.block1.bias"
          ),
          "adapter.body.2.resnets.0.block2.weight": src_state.pop(
              "body.2.body.0.block2.weight"
          ),
          "adapter.body.2.resnets.0.block2.bias": src_state.pop(
              "body.2.body.0.block2.bias"
          ),
          # body.2.body.1
          "adapter.body.2.resnets.1.block1.weight": src_state.pop(
              "body.2.body.1.block1.weight"
          ),
          "adapter.body.2.resnets.1.block1.bias": src_state.pop(
              "body.2.body.1.block1.bias"
          ),
          "adapter.body.2.resnets.1.block2.weight": src_state.pop(
              "body.2.body.1.block2.weight"
          ),
          "adapter.body.2.resnets.1.block2.bias": src_state.pop(
              "body.2.body.1.block2.bias"
          ),
          # body.2.body.2
          "adapter.body.2.resnets.2.block1.weight": src_state.pop(
              "body.2.body.2.block1.weight"
          ),
          "adapter.body.2.resnets.2.block1.bias": src_state.pop(
              "body.2.body.2.block1.bias"
          ),
          "adapter.body.2.resnets.2.block2.weight": src_state.pop(
              "body.2.body.2.block2.weight"
          ),
          "adapter.body.2.resnets.2.block2.bias": src_state.pop(
              "body.2.body.2.block2.bias"
          ),
          # body.2.body.3
          "adapter.body.2.resnets.3.block1.weight": src_state.pop(
              "body.2.body.3.block1.weight"
          ),
          "adapter.body.2.resnets.3.block1.bias": src_state.pop(
              "body.2.body.3.block1.bias"
          ),
          "adapter.body.2.resnets.3.block2.weight": src_state.pop(
              "body.2.body.3.block2.weight"
          ),
          "adapter.body.2.resnets.3.block2.bias": src_state.pop(
              "body.2.body.3.block2.bias"
          ),
          # body.2.out_conv
          "adapter.body.2.out_conv.weight": src_state.pop(
              "body.2.out_conv.weight"
          ),
          "adapter.body.2.out_conv.bias": src_state.pop(
              "body.2.out_conv.bias"
          ),
          # body.3.in_conv
          "adapter.body.3.in_conv.weight": src_state.pop(
              "body.3.in_conv.weight"
          ),
          "adapter.body.3.in_conv.bias": src_state.pop(
              "body.3.in_conv.bias"
          ),
          # body.3.body.0
          "adapter.body.3.resnets.0.block1.weight": src_state.pop(
              "body.3.body.0.block1.weight"
          ),
          "adapter.body.3.resnets.0.block1.bias": src_state.pop(
              "body.3.body.0.block1.bias"
          ),
          "adapter.body.3.resnets.0.block2.weight": src_state.pop(
              "body.3.body.0.block2.weight"
          ),
          "adapter.body.3.resnets.0.block2.bias": src_state.pop(
              "body.3.body.0.block2.bias"
          ),
          # body.3.body.1
          "adapter.body.3.resnets.1.block1.weight": src_state.pop(
              "body.3.body.1.block1.weight"
          ),
          "adapter.body.3.resnets.1.block1.bias": src_state.pop(
              "body.3.body.1.block1.bias"
          ),
          "adapter.body.3.resnets.1.block2.weight": src_state.pop(
              "body.3.body.1.block2.weight"
          ),
          "adapter.body.3.resnets.1.block2.bias": src_state.pop(
              "body.3.body.1.block2.bias"
          ),
          # body.3.body.2
          "adapter.body.3.resnets.2.block1.weight": src_state.pop(
              "body.3.body.2.block1.weight"
          ),
          "adapter.body.3.resnets.2.block1.bias": src_state.pop(
              "body.3.body.2.block1.bias"
          ),
          "adapter.body.3.resnets.2.block2.weight": src_state.pop(
              "body.3.body.2.block2.weight"
          ),
          "adapter.body.3.resnets.2.block2.bias": src_state.pop(
              "body.3.body.2.block2.bias"
          ),
          # body.3.body.3
          "adapter.body.3.resnets.3.block1.weight": src_state.pop(
              "body.3.body.3.block1.weight"
          ),
          "adapter.body.3.resnets.3.block1.bias": src_state.pop(
              "body.3.body.3.block1.bias"
          ),
          "adapter.body.3.resnets.3.block2.weight": src_state.pop(
              "body.3.body.3.block2.weight"
          ),
          "adapter.body.3.resnets.3.block2.bias": src_state.pop(
              "body.3.body.3.block2.bias"
          ),
          # body.3.out_conv
          "adapter.body.3.out_conv.weight": src_state.pop(
              "body.3.out_conv.weight"
          ),
          "adapter.body.3.out_conv.bias": src_state.pop(
              "body.3.out_conv.bias"
          ),
      }
  
      assert len(src_state) == 0
  
      adapter = T2IAdapter(
          in_channels=3,
          channels=[320, 640, 1280],
          num_res_blocks=4,
          adapter_type="light_adapter",
      )
  
      adapter.load_state_dict(res_state)
  
      return adapter
  
imports: import argparse
  import torch
  from diffusers import T2IAdapter
label_desc: Use image node_id 2 for calling a global function with example usage: convert_light_adapter(src_state) and returns: adapter