code: def convert_dpt_checkpoint(
      checkpoint_url, pytorch_dump_folder_path, push_to_hub, model_name
  ):
      """
      Copy/paste/tweak model's weights to our DPT structure.
      """
  
      # define DPT configuration based on URL
      config, expected_shape = get_dpt_config(checkpoint_url)
      # load original state_dict from URL
      state_dict = torch.hub.load_state_dict_from_url(
          checkpoint_url, map_location="cpu"
      )
      # remove certain keys
      remove_ignore_keys_(state_dict)
      # rename keys
      for key in state_dict.copy().keys():
          val = state_dict.pop(key)
          state_dict[rename_key(key)] = val
      # read in qkv matrices
      read_in_q_k_v(state_dict, config)
  
      # load HuggingFace model
      model = (
          DPTForSemanticSegmentation(config)
          if "ade" in checkpoint_url
          else DPTForDepthEstimation(config)
      )
      model.load_state_dict(state_dict)
      model.eval()
  
      # Check outputs on an image
      size = 480 if "ade" in checkpoint_url else 384
      feature_extractor = DPTFeatureExtractor(size=size)
  
      image = prepare_img()
      encoding = feature_extractor(image, return_tensors="pt")
  
      # forward pass
      outputs = (
          model(**encoding).logits
          if "ade" in checkpoint_url
          else model(**encoding).predicted_depth
      )
  
      # Assert logits
      expected_slice = torch.tensor(
          [
              [6.3199, 6.3629, 6.4148],
              [6.3850, 6.3615, 6.4166],
              [6.3519, 6.3176, 6.3575],
          ]
      )
      if "ade" in checkpoint_url:
          expected_slice = torch.tensor(
              [
                  [4.0480, 4.2420, 4.4360],
                  [4.3124, 4.5693, 4.8261],
                  [4.5768, 4.8965, 5.2163],
              ]
          )
      assert outputs.shape == torch.Size(expected_shape)
      assert (
          torch.allclose(
              outputs[0, 0, :3, :3], expected_slice, atol=1e-4
          )
          if "ade" in checkpoint_url
          else torch.allclose(outputs[0, :3, :3], expected_slice)
      )
  
      Path(pytorch_dump_folder_path).mkdir(exist_ok=True)
      print(f"Saving model to {pytorch_dump_folder_path}")
      model.save_pretrained(pytorch_dump_folder_path)
      print(f"Saving feature extractor to {pytorch_dump_folder_path}")
      feature_extractor.save_pretrained(pytorch_dump_folder_path)
  
      if push_to_hub:
          print("Pushing model to hub...")
          model.push_to_hub(
              repo_path_or_name=Path(
                  pytorch_dump_folder_path, model_name
              ),
              organization="nielsr",
              commit_message="Add model",
              use_temp_dir=True,
          )
          feature_extractor.push_to_hub(
              repo_path_or_name=Path(
                  pytorch_dump_folder_path, model_name
              ),
              organization="nielsr",
              commit_message="Add feature extractor",
              use_temp_dir=True,
          )
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/dpt/convert_dpt_to_pytorch.py
imports: import argparse
  import json
  from pathlib import Path
  import torch
  from PIL import Image
  import requests
  from huggingface_hub import cached_download, hf_hub_url
  from transformers import DPTConfig, DPTFeatureExtractor, DPTForDepthEstimation, DPTForSemanticSegmentation
  from transformers.utils import logging
label_desc: Use image node_id 6 for calling a global function with example usage: convert_dpt_checkpoint(checkpoint_url, pytorch_dump_folder_path, push_to_hub, model_name) without return types