code: def convert_state_dict(orig_state_dict, config):
      for key in orig_state_dict.copy().keys():
          val = orig_state_dict.pop(key)
  
          if "qkv" in key:
              key_split = key.split(".")
              stage_num = int(key_split[1])
              block_num = int(key_split[4])
              dim = config.embed_dim
  
              if "weight" in key:
                  orig_state_dict[
                      f"swin2sr.encoder.stages.{stage_num}.layers.{block_num}.attention.self.query.weight"
                  ] = val[:dim, :]
                  orig_state_dict[
                      f"swin2sr.encoder.stages.{stage_num}.layers.{block_num}.attention.self.key.weight"
                  ] = val[dim : dim * 2, :]
                  orig_state_dict[
                      f"swin2sr.encoder.stages.{stage_num}.layers.{block_num}.attention.self.value.weight"
                  ] = val[-dim:, :]
              else:
                  orig_state_dict[
                      f"swin2sr.encoder.stages.{stage_num}.layers.{block_num}.attention.self.query.bias"
                  ] = val[:dim]
                  orig_state_dict[
                      f"swin2sr.encoder.stages.{stage_num}.layers.{block_num}.attention.self.key.bias"
                  ] = val[dim : dim * 2]
                  orig_state_dict[
                      f"swin2sr.encoder.stages.{stage_num}.layers.{block_num}.attention.self.value.bias"
                  ] = val[-dim:]
              pass
          else:
              orig_state_dict[rename_key(key, config)] = val
  
      return orig_state_dict
  
file_path: transformers/src/transformers/models/swin2sr/convert_swin2sr_original_to_pytorch.py
imports: import argparse
  import requests
  import torch
  from PIL import Image
  from torchvision.transforms import Compose, Normalize, Resize, ToTensor
  from transformers import Swin2SRConfig, Swin2SRForImageSuperResolution, Swin2SRImageProcessor
label_desc: Use image node_id 3 for calling a global function with example usage: convert_state_dict(orig_state_dict, config) and returns: orig_state_dict