code: def load_optimized_unet(
      cache_dir=None,
      unet_attributes=None,
      accelerator="openvino",
      ipex=True,
      precision="float32",
      device="CPU",
      low_memory=False,
      lora_name=None,
      additional_suffix=None,
  ):
      t_start = time.perf_counter()
      if cache_dir is None and unet_attributes is None:
          print(
              f"You should provide either unet_attributes or cache_dir."
          )
          return None
      if cache_dir is None:
          cache_dir = unet_attributes["config"]._name_or_path
      if unet_attributes is None:
          attr_file_path = os.path.join(cache_dir, "attrs.pkl")
          if os.path.exists(attr_file_path):
              import pickle
  
              with open(attr_file_path, "rb") as f:
                  unet_attributes = pickle.load(f)
          elif os.path.exists(os.path.join(cache_dir, "config.json")):
              import json
              from diffusers.configuration_utils import FrozenDict
  
              with open(os.path.join(cache_dir, "config.json")) as f:
                  unet_attributes = {}
                  conf = json.load(f)
                  conf_obj = FrozenDict(conf)
                  unet_attributes["config"] = conf_obj
                  unet_attributes[
                      "conv_in_in_channels"
                  ] = unet_attributes["config"].in_channels
                  unet_attributes["in_channels"] = unet_attributes[
                      "config"
                  ].in_channels
          else:
              print(
                  f"Cannot find the unet attributes file or config.json, \
                    please provide unet_attributes or config.json."
              )
      conv_in = OrderedDict()
      conv_in.in_channels = unet_attributes["conv_in_in_channels"]
  
      nano_unet, expect_path = try_load_existing_model(
          unet_attributes,
          cache_dir,
          accelerator=accelerator,
          ipex=ipex,
          precision=precision,
          low_memory=low_memory,
          device=device,
          additional_suffix=additional_suffix,
          lora_name=lora_name,
      )
      t_end = time.perf_counter()
      if nano_unet is None:
          raise Exception(
              f"You have to download the \
                          optimized nano unet models. \
                          Expected path: {expect_path}"
          )
      else:
          print(f"Load unet in {t_end - t_start}s")
          setattr(nano_unet, "conv_in", conv_in)
          setattr(nano_unet.config, "_name_or_path", cache_dir)
      return nano_unet
  
file_path: BigDL/python/nano/src/bigdl/nano/diffusion/common/load.py
imports: import os
  import time
  from collections import OrderedDict
  from huggingface_hub import snapshot_download
  from bigdl.nano.pytorch import InferenceOptimizer
label_desc: Use image node_id 3 for calling a global function with example usage: load_optimized_unet(cache_dir, unet_attributes, accelerator, ipex, precision, device, low_memory, lora_name, additional_suffix) and returns: nano_unet, None