code: def save_hypernetwork(
      hypernetwork, checkpoint, hypernetwork_name, filename
  ):
      old_hypernetwork_name = hypernetwork.name
      old_sd_checkpoint = (
          hypernetwork.sd_checkpoint
          if hasattr(hypernetwork, "sd_checkpoint")
          else None
      )
      old_sd_checkpoint_name = (
          hypernetwork.sd_checkpoint_name
          if hasattr(hypernetwork, "sd_checkpoint_name")
          else None
      )
      try:
          hypernetwork.sd_checkpoint = checkpoint.shorthash
          hypernetwork.sd_checkpoint_name = checkpoint.model_name
          hypernetwork.name = hypernetwork_name
          hypernetwork.save(filename)
      except:
          hypernetwork.sd_checkpoint = old_sd_checkpoint
          hypernetwork.sd_checkpoint_name = old_sd_checkpoint_name
          hypernetwork.name = old_hypernetwork_name
          raise
  
imports: import datetime
  import glob
  import html
  import os
  import inspect
  from contextlib import closing
  import modules.textual_inversion.dataset
  import torch
  import tqdm
  from einops import rearrange, repeat
  from ldm.util import default
  from modules import devices, sd_models, shared, sd_samplers, hashes, sd_hijack_checkpoint, errors
  from modules.textual_inversion import textual_inversion, logging
  from modules.textual_inversion.learn_schedule import LearnRateScheduler
  from torch import einsum
  from torch.nn.init import normal_, xavier_normal_, xavier_uniform_, kaiming_normal_, kaiming_uniform_, zeros_
  from collections import deque
  from statistics import stdev, mean
label_desc: Use image node_id 12 for calling a global function with example usage: save_hypernetwork(hypernetwork, checkpoint, hypernetwork_name, filename) without return types