code: def _load_ipex(pipe, device, precision):
      if precision == "float32":
          vae = InferenceOptimizer.trace(
              pipe.vae, device=device, use_ipex=True, channels_last=True
          )
          text_encoder = InferenceOptimizer.trace(
              pipe.text_encoder,
              device=device,
              use_ipex=True,
              channels_last=True,
          )
          unet = InferenceOptimizer.trace(
              pipe.unet,
              device=device,
              use_ipex=True,
              channels_last=True,
          )
      elif precision == "bfloat16":
          vae = InferenceOptimizer.quantize(
              pipe.vae, device=device, use_ipex=True, precision="bf16"
          )
          text_encoder = InferenceOptimizer.quantize(
              pipe.text_encoder,
              device=device,
              use_ipex=True,
              precision="bf16",
          )
          unet = InferenceOptimizer.quantize(
              pipe.unet, device=device, use_ipex=True, precision="bf16"
          )
      elif precision == "float16":
          vae = InferenceOptimizer.quantize(
              pipe.vae,
              device=device,
              use_ipex=True,
              channels_last=True,
              precision="fp16",
          )
          text_encoder = InferenceOptimizer.quantize(
              pipe.text_encoder,
              device=device,
              use_ipex=True,
              channels_last=True,
              precision="fp16",
          )
          unet = InferenceOptimizer.quantize(
              pipe.unet,
              device=device,
              use_ipex=True,
              channels_last=True,
              precision="fp16",
          )
      else:
          raise ValueError(
              f'Unsupported precision {precision}, \
                           available options are: {["float32", "bfloat16", "float16"]}'
          )
      pipe.vae = vae
      pipe.text_encoder = text_encoder
      pipe.unet = unet
  
imports: import os
  import functools
  import diffusers
  from huggingface_hub import snapshot_download
  from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
  from diffusers import DiffusionPipeline, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline
  from diffusers import AutoencoderKL, UNet2DConditionModel
  from bigdl.nano.diffusion.utils.paths import *
  from bigdl.nano.pytorch import InferenceOptimizer
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.diffusion.common.optimize import load_optimized_unet, load_optimized_vae_decoder
label_desc: Use image node_id 4 for calling a global function with example usage: _load_ipex(pipe, device, precision) without return types