code: def convert_state_dict(orig_state_dict, config):
      for key in orig_state_dict.copy().keys():
          val = orig_state_dict.pop(key)
  
          if key.startswith("encoder."):
              key = key.replace("encoder.", "")
  
          if "qkv" in key:
              key_split = key.split(".")
              if key.startswith("decoder.blocks"):
                  dim = config.decoder_hidden_size
                  layer_num = int(key_split[2])
                  prefix = "decoder.decoder_layers."
                  if "weight" in key:
                      orig_state_dict[
                          f"{prefix}{layer_num}.attention.attention.query.weight"
                      ] = val[:dim, :]
                      orig_state_dict[
                          f"{prefix}{layer_num}.attention.attention.key.weight"
                      ] = val[dim : dim * 2, :]
                      orig_state_dict[
                          f"{prefix}{layer_num}.attention.attention.value.weight"
                      ] = val[-dim:, :]
              else:
                  dim = config.hidden_size
                  layer_num = int(key_split[1])
                  prefix = "videomae.encoder.layer."
                  if "weight" in key:
                      orig_state_dict[
                          f"{prefix}{layer_num}.attention.attention.query.weight"
                      ] = val[:dim, :]
                      orig_state_dict[
                          f"{prefix}{layer_num}.attention.attention.key.weight"
                      ] = val[dim : dim * 2, :]
                      orig_state_dict[
                          f"{prefix}{layer_num}.attention.attention.value.weight"
                      ] = val[-dim:, :]
          else:
              orig_state_dict[rename_key(key)] = val
  
      return orig_state_dict
  
file_path: transformers/src/transformers/models/videomae/convert_videomae_to_pytorch.py
imports: import argparse
  import json
  import gdown
  import numpy
  import torch
  from huggingface_hub import hf_hub_download
  from transformers import VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor
label_desc: Use image node_id 4 for calling a global function with example usage: convert_state_dict(orig_state_dict, config) and returns: orig_state_dict