code: def set_recursively(hf_pointer, key, value, full_name, weight_type):
      for attribute in key.split("."):
          hf_pointer = getattr(hf_pointer, attribute)
  
      if weight_type is not None:
          hf_shape = getattr(hf_pointer, weight_type).shape
      else:
          hf_shape = hf_pointer.shape
  
      # strip off the kernel dimension at the end (original weights are Conv1d)
      if (
          key.endswith(".k_proj")
          or key.endswith(".v_proj")
          or key.endswith(".q_proj")
          or key.endswith(".out_proj")
      ):
          value = value.squeeze(-1)
  
      if hf_shape != value.shape:
          raise ValueError(
              f"Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be"
              f" {value.shape} for {full_name}"
          )
  
      if weight_type == "weight":
          hf_pointer.weight.data = value
      elif weight_type == "weight_g":
          hf_pointer.weight_g.data = value
      elif weight_type == "weight_v":
          hf_pointer.weight_v.data = value
      elif weight_type == "bias":
          hf_pointer.bias.data = value
      elif weight_type == "running_mean":
          hf_pointer.running_mean.data = value
      elif weight_type == "running_var":
          hf_pointer.running_var.data = value
      elif weight_type == "num_batches_tracked":
          hf_pointer.num_batches_tracked.data = value
      else:
          hf_pointer.data = value
  
      logger.info(
          f"{key + ('.' + weight_type if weight_type is not None else '')} was initialized from {full_name}."
      )
  
file_path: transformers/src/transformers/models/vits/convert_original_checkpoint.py
imports: import argparse
  import json
  import tempfile
  import torch
  from huggingface_hub import hf_hub_download
  from transformers import VitsConfig, VitsModel, VitsTokenizer, logging
label_desc: Use image node_id 1 for calling a global function with example usage: set_recursively(hf_pointer, key, value, full_name, weight_type) without return types