code: def resrgan2normal(state_dict, nb=23):
      # this code is copied from https://github.com/victorca25/iNNfer
      if (
          "conv_first.weight" in state_dict
          and "body.0.rdb1.conv1.weight" in state_dict
      ):
          re8x = 0
          crt_net = {}
          items = list(state_dict)
  
          crt_net["model.0.weight"] = state_dict["conv_first.weight"]
          crt_net["model.0.bias"] = state_dict["conv_first.bias"]
  
          for k in items.copy():
              if "rdb" in k:
                  ori_k = k.replace("body.", "model.1.sub.")
                  ori_k = ori_k.replace(".rdb", ".RDB")
                  if ".weight" in k:
                      ori_k = ori_k.replace(".weight", ".0.weight")
                  elif ".bias" in k:
                      ori_k = ori_k.replace(".bias", ".0.bias")
                  crt_net[ori_k] = state_dict[k]
                  items.remove(k)
  
          crt_net[f"model.1.sub.{nb}.weight"] = state_dict[
              "conv_body.weight"
          ]
          crt_net[f"model.1.sub.{nb}.bias"] = state_dict[
              "conv_body.bias"
          ]
          crt_net["model.3.weight"] = state_dict["conv_up1.weight"]
          crt_net["model.3.bias"] = state_dict["conv_up1.bias"]
          crt_net["model.6.weight"] = state_dict["conv_up2.weight"]
          crt_net["model.6.bias"] = state_dict["conv_up2.bias"]
  
          if "conv_up3.weight" in state_dict:
              # modification supporting: https://github.com/ai-forever/Real-ESRGAN/blob/main/RealESRGAN/rrdbnet_arch.py
              re8x = 3
              crt_net["model.9.weight"] = state_dict["conv_up3.weight"]
              crt_net["model.9.bias"] = state_dict["conv_up3.bias"]
  
          crt_net[f"model.{8+re8x}.weight"] = state_dict[
              "conv_hr.weight"
          ]
          crt_net[f"model.{8+re8x}.bias"] = state_dict["conv_hr.bias"]
          crt_net[f"model.{10+re8x}.weight"] = state_dict[
              "conv_last.weight"
          ]
          crt_net[f"model.{10+re8x}.bias"] = state_dict[
              "conv_last.bias"
          ]
  
          state_dict = crt_net
      return state_dict
  
file_path: stable-diffusion-webui/modules/esrgan_model.py
imports: import sys
  import numpy
  import torch
  from PIL import Image
  import modules.esrgan_model_arch
  from modules import modelloader, images, devices
  from modules.shared import opts
  from modules.upscaler import Upscaler, UpscalerData
label_desc: Use image node_id 2 for calling a global function with example usage: resrgan2normal(state_dict, nb) and returns: state_dict