code: def load_optimized_controlnet(
      controlnet=None,
      model_id=None,
      local_controlnet_dir=None,
      accelerator="jit",
      ipex=True,
      precision="float32",
      device="CPU",
      low_memory=False,
  ):
      t_start = time.perf_counter()
      # TODO: here just got model id, not the model dir, need a better way to obtain dir
      if controlnet is not None:
          name_or_path = controlnet._name_or_path
      else:
          name_or_path = model_id
      if not os.path.exists(name_or_path):
          name_or_path = snapshot_download(
              name_or_path,
              cache_dir=local_controlnet_dir,
              local_files_only=True,
          )
      nano_controlnet, cache_path = try_load_existing_model(
          {},
          name_or_path,
          accelerator=accelerator,
          ipex=ipex,
          precision=precision,
          low_memory=low_memory,
          device=device,
      )
      t_end = time.perf_counter()
      if nano_controlnet is None:
          raise Exception(
              f"You have to download the\
                          optimized nano unet models. Expected path: {name_or_path}"
          )
      print(f"Load controlnet from {cache_path} in {t_end - t_start}s")
      return nano_controlnet
  
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 5 for calling a global function with example usage: load_optimized_controlnet(controlnet, model_id, local_controlnet_dir, accelerator, ipex, precision, device, low_memory) and returns: nano_controlnet