code: def create_rename_keys(config, has_lm_head=False, is_semantic=False):
      prefix = "backbone." if is_semantic else ""
  
      rename_keys = []
      for i in range(config.num_hidden_layers):
          # encoder layers: output projection, 2 feedforward neural networks and 2 layernorms
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.norm1.weight",
                  f"beit.encoder.layer.{i}.layernorm_before.weight",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.norm1.bias",
                  f"beit.encoder.layer.{i}.layernorm_before.bias",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.attn.proj.weight",
                  f"beit.encoder.layer.{i}.attention.output.dense.weight",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.attn.proj.bias",
                  f"beit.encoder.layer.{i}.attention.output.dense.bias",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.norm2.weight",
                  f"beit.encoder.layer.{i}.layernorm_after.weight",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.norm2.bias",
                  f"beit.encoder.layer.{i}.layernorm_after.bias",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.mlp.fc1.weight",
                  f"beit.encoder.layer.{i}.intermediate.dense.weight",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.mlp.fc1.bias",
                  f"beit.encoder.layer.{i}.intermediate.dense.bias",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.mlp.fc2.weight",
                  f"beit.encoder.layer.{i}.output.dense.weight",
              )
          )
          rename_keys.append(
              (
                  f"{prefix}blocks.{i}.mlp.fc2.bias",
                  f"beit.encoder.layer.{i}.output.dense.bias",
              )
          )
  
      # projection layer + position embeddings
      rename_keys.extend(
          [
              (f"{prefix}cls_token", "beit.embeddings.cls_token"),
              (
                  f"{prefix}patch_embed.proj.weight",
                  "beit.embeddings.patch_embeddings.projection.weight",
              ),
              (
                  f"{prefix}patch_embed.proj.bias",
                  "beit.embeddings.patch_embeddings.projection.bias",
              ),
              (
                  f"{prefix}pos_embed",
                  "beit.embeddings.position_embeddings",
              ),
          ]
      )
  
      if has_lm_head:
          # mask token + layernorm
          rename_keys.extend(
              [
                  ("mask_token", "beit.embeddings.mask_token"),
                  ("norm.weight", "layernorm.weight"),
                  ("norm.bias", "layernorm.bias"),
              ]
          )
      else:
          # layernorm + classification head
          rename_keys.extend(
              [
                  ("fc_norm.weight", "beit.pooler.layernorm.weight"),
                  ("fc_norm.bias", "beit.pooler.layernorm.bias"),
                  ("head.weight", "classifier.weight"),
                  ("head.bias", "classifier.bias"),
              ]
          )
  
      return rename_keys
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/dit/convert_dit_unilm_to_pytorch.py
imports: import argparse
  import json
  from pathlib import Path
  import torch
  from PIL import Image
  import requests
  from huggingface_hub import hf_hub_download
  from transformers import BeitConfig, BeitFeatureExtractor, BeitForImageClassification, BeitForMaskedImageModeling
  from transformers.image_utils import PILImageResampling
  from transformers.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: create_rename_keys(config, has_lm_head, is_semantic) and returns: rename_keys