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(".")
              layer_num = int(key_split[3])
              dim = config.hidden_size
              if "weight" in key:
                  orig_state_dict[
                      f"audio_spectrogram_transformer.encoder.layer.{layer_num}.attention.attention.query.weight"
                  ] = val[:dim, :]
                  orig_state_dict[
                      f"audio_spectrogram_transformer.encoder.layer.{layer_num}.attention.attention.key.weight"
                  ] = val[dim : dim * 2, :]
                  orig_state_dict[
                      f"audio_spectrogram_transformer.encoder.layer.{layer_num}.attention.attention.value.weight"
                  ] = val[-dim:, :]
              else:
                  orig_state_dict[
                      f"audio_spectrogram_transformer.encoder.layer.{layer_num}.attention.attention.query.bias"
                  ] = val[:dim]
                  orig_state_dict[
                      f"audio_spectrogram_transformer.encoder.layer.{layer_num}.attention.attention.key.bias"
                  ] = val[dim : dim * 2]
                  orig_state_dict[
                      f"audio_spectrogram_transformer.encoder.layer.{layer_num}.attention.attention.value.bias"
                  ] = val[-dim:]
          else:
              orig_state_dict[rename_key(key)] = val
  
      return orig_state_dict
  
file_path: transformers/src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.py
imports: import argparse
  import json
  from pathlib import Path
  import torch
  import torchaudio
  from datasets import load_dataset
  from huggingface_hub import hf_hub_download
  from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification
  from transformers.utils import logging
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