code: def convert_weights_and_push(
      save_directory: Path,
      model_name: str = None,
      push_to_hub: bool = True,
  ):
      filename = "imagenet-1k-id2label.json"
      num_labels = 1000
      expected_shape = (1, num_labels)
  
      repo_id = "huggingface/label-files"
      num_labels = num_labels
      id2label = json.load(
          open(
              hf_hub_download(repo_id, filename, repo_type="dataset"),
              "r",
          )
      )
      id2label = {int(k): v for k, v in id2label.items()}
  
      id2label = id2label
      label2id = {v: k for k, v in id2label.items()}
  
      ImageNetPreTrainedConfig = partial(
          LevitConfig,
          num_labels=num_labels,
          id2label=id2label,
          label2id=label2id,
      )
  
      names_to_hidden_sizes = {
          "levit-128S": 128,
          "levit-128": 128,
          "levit-192": 192,
          "levit-256": 256,
          "levit-384": 384,
      }
  
      names_to_config = {
          "levit-128S": ImageNetPreTrainedConfig(
              hidden_sizes=[128, 256, 384],
              num_attention_heads=[4, 6, 8],
              depths=[2, 3, 4],
              key_dim=[16, 16, 16],
              drop_path_rate=0,
          ),
          "levit-128": ImageNetPreTrainedConfig(
              hidden_sizes=[128, 256, 384],
              num_attention_heads=[4, 8, 12],
              depths=[4, 4, 4],
              key_dim=[16, 16, 16],
              drop_path_rate=0,
          ),
          "levit-192": ImageNetPreTrainedConfig(
              hidden_sizes=[192, 288, 384],
              num_attention_heads=[3, 5, 6],
              depths=[4, 4, 4],
              key_dim=[32, 32, 32],
              drop_path_rate=0,
          ),
          "levit-256": ImageNetPreTrainedConfig(
              hidden_sizes=[256, 384, 512],
              num_attention_heads=[4, 6, 8],
              depths=[4, 4, 4],
              key_dim=[32, 32, 32],
              drop_path_rate=0,
          ),
          "levit-384": ImageNetPreTrainedConfig(
              hidden_sizes=[384, 512, 768],
              num_attention_heads=[6, 9, 12],
              depths=[4, 4, 4],
              key_dim=[32, 32, 32],
              drop_path_rate=0.1,
          ),
      }
  
      if model_name:
          convert_weight_and_push(
              names_to_hidden_sizes[model_name],
              model_name,
              names_to_config[model_name],
              save_directory,
              push_to_hub,
          )
      else:
          for model_name, config in names_to_config.items():
              convert_weight_and_push(
                  names_to_hidden_sizes[model_name],
                  model_name,
                  config,
                  save_directory,
                  push_to_hub,
              )
      return config, expected_shape
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/levit/convert_levit_timm_to_pytorch.py
imports: import argparse
  import json
  from collections import OrderedDict
  from functools import partial
  from pathlib import Path
  import torch
  import timm
  from huggingface_hub import hf_hub_download
  from transformers import LevitConfig, LevitFeatureExtractor, LevitForImageClassificationWithTeacher
  from transformers.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: convert_weights_and_push(save_directory, model_name, push_to_hub) and returns: config,  expected_shape