code: def read_in_q_k_v(state_dict, backbone_config):
      num_features = [
          int(backbone_config.embed_dim * 2**i)
          for i in range(len(backbone_config.depths))
      ]
      for i in range(len(backbone_config.depths)):
          dim = num_features[i]
          for j in range(backbone_config.depths[i]):
              # fmt: off
              # read in weights + bias of input projection layer (in original implementation, this is a single matrix + bias)
              in_proj_weight = state_dict.pop(f"backbone.stages.{i}.blocks.{j}.attn.w_msa.qkv.weight")
              in_proj_bias = state_dict.pop(f"backbone.stages.{i}.blocks.{j}.attn.w_msa.qkv.bias")
              # next, add query, keys and values (in that order) to the state dict
              state_dict[f"backbone.encoder.layers.{i}.blocks.{j}.attention.self.query.weight"] = in_proj_weight[:dim, :]
              state_dict[f"backbone.encoder.layers.{i}.blocks.{j}.attention.self.query.bias"] = in_proj_bias[: dim]
              state_dict[f"backbone.encoder.layers.{i}.blocks.{j}.attention.self.key.weight"] = in_proj_weight[
                  dim : dim * 2, :
              ]
              state_dict[f"backbone.encoder.layers.{i}.blocks.{j}.attention.self.key.bias"] = in_proj_bias[
                  dim : dim * 2
              ]
              state_dict[f"backbone.encoder.layers.{i}.blocks.{j}.attention.self.value.weight"] = in_proj_weight[
                  -dim :, :
              ]
              state_dict[f"backbone.encoder.layers.{i}.blocks.{j}.attention.self.value.bias"] = in_proj_bias[-dim :]
  
file_path: transformers/src/transformers/models/upernet/convert_swin_upernet_to_pytorch.py
imports: import argparse
  import json
  import requests
  import torch
  from huggingface_hub import hf_hub_download
  from PIL import Image
  from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation
label_desc: Use image node_id 4 for calling a global function with example usage: read_in_q_k_v(state_dict, backbone_config) without return types