code: def load(self, filename):
      self.filename = filename
      if self.name is None:
          self.name = os.path.splitext(os.path.basename(filename))[0]
  
      state_dict = torch.load(filename, map_location="cpu")
  
      self.layer_structure = state_dict.get(
          "layer_structure", [1, 2, 1]
      )
      self.optional_info = state_dict.get("optional_info", None)
      self.activation_func = state_dict.get("activation_func", None)
      self.weight_init = state_dict.get(
          "weight_initialization", "Normal"
      )
      self.add_layer_norm = state_dict.get("is_layer_norm", False)
      self.dropout_structure = state_dict.get("dropout_structure", None)
      self.use_dropout = (
          True
          if self.dropout_structure is not None
          and any(self.dropout_structure)
          else state_dict.get("use_dropout", False)
      )
      self.activate_output = state_dict.get("activate_output", True)
      self.last_layer_dropout = state_dict.get(
          "last_layer_dropout", False
      )
      # Dropout structure should have same length as layer structure, Every digits should be in [0,1), and last digit must be 0.
      if self.dropout_structure is None:
          self.dropout_structure = parse_dropout_structure(
              self.layer_structure,
              self.use_dropout,
              self.last_layer_dropout,
          )
  
      if shared.opts.print_hypernet_extra:
          if self.optional_info is not None:
              print(f"  INFO:\n {self.optional_info}\n")
  
          print(f"  Layer structure: {self.layer_structure}")
          print(f"  Activation function: {self.activation_func}")
          print(f"  Weight initialization: {self.weight_init}")
          print(f"  Layer norm: {self.add_layer_norm}")
          print(f"  Dropout usage: {self.use_dropout}")
          print(f"  Activate last layer: {self.activate_output}")
          print(f"  Dropout structure: {self.dropout_structure}")
  
      optimizer_saved_dict = (
          torch.load(self.filename + ".optim", map_location="cpu")
          if os.path.exists(self.filename + ".optim")
          else {}
      )
  
      if self.shorthash() == optimizer_saved_dict.get("hash", None):
          self.optimizer_state_dict = optimizer_saved_dict.get(
              "optimizer_state_dict", None
          )
      else:
          self.optimizer_state_dict = None
      if self.optimizer_state_dict:
          self.optimizer_name = optimizer_saved_dict.get(
              "optimizer_name", "AdamW"
          )
          if shared.opts.print_hypernet_extra:
              print("Loaded existing optimizer from checkpoint")
              print(f"Optimizer name is {self.optimizer_name}")
      else:
          self.optimizer_name = "AdamW"
          if shared.opts.print_hypernet_extra:
              print("No saved optimizer exists in checkpoint")
  
      for size, sd in state_dict.items():
          if type(size) == int:
              self.layers[size] = (
                  HypernetworkModule(
                      size,
                      sd[0],
                      self.layer_structure,
                      self.activation_func,
                      self.weight_init,
                      self.add_layer_norm,
                      self.activate_output,
                      self.dropout_structure,
                  ),
                  HypernetworkModule(
                      size,
                      sd[1],
                      self.layer_structure,
                      self.activation_func,
                      self.weight_init,
                      self.add_layer_norm,
                      self.activate_output,
                      self.dropout_structure,
                  ),
              )
  
      self.name = state_dict.get("name", self.name)
      self.step = state_dict.get("step", 0)
      self.sd_checkpoint = state_dict.get("sd_checkpoint", None)
      self.sd_checkpoint_name = state_dict.get(
          "sd_checkpoint_name", None
      )
      self.eval()
  
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 8 for calling the Hypernetwork obj's underlying member method code with example usage: obj.load(filename) without return types