class_docstr: NanoDiffusionPipeline.
class_docstr_tok: ["NanoDiffusionPipeline","."]
docstr: Get the pretrained model.
docstr_tok: ["Get","the","pretrained","model","."]
code: def from_pretrained(
      cls: DiffusionPipeline,
      pretrained_model_name_or_path,
      scheduler=default_scheduler,
      device="CPU",
      precision="bfloat16",
      backend="IPEX",
      **kwargs,
  ):
      """Get the pretrained model."""
      scheduler = scheduler_map[scheduler].from_pretrained(
          pretrained_model_name_or_path, subfolder="scheduler"
      )
      # load pipeline
      if backend.lower() == "ov":
          if not os.path.exists(pretrained_model_name_or_path):
              try:
                  pretrained_model_name_or_path = snapshot_download(
                      pretrained_model_name_or_path
                  )
              except Exception:
                  msg = "Could not find local `model_path` in given local path, \
                                            could not find the model on Huggingface Hub \
                                            by given `model_path` as repo_id either."
  
                  invalidInputError(False, errMsg=msg)
          ov_unet, ov_vae_decoder = _preload_ov(
              pretrained_model_name_or_path, device, precision
          )
  
          text_encoder = CLIPTextModel.from_pretrained(
              pretrained_model_name_or_path, subfolder="text_encoder"
          )
          tokenizer = CLIPTokenizer.from_pretrained(
              pretrained_model_name_or_path, subfolder="tokenizer"
          )
          safety_checker = kwargs.get("safety_checker", None)
          feature_extractor = CLIPFeatureExtractor.from_pretrained(
              pretrained_model_name_or_path,
              subfolder="feature_extractor",
          )
          requires_safety_checker = kwargs.get(
              "requires_safety_checker", False
          )
          # do not load unet/vae to save RAM
          dummy_unet = UNet2DConditionModel()
          # TODO create a new config without preloading ov for the next line
          dummy_unet._internal_dict = ov_unet.config  # TODO
          dummy_vae = AutoencoderKL.from_pretrained(
              pretrained_model_name_or_path, subfolder="vae"
          )
          pipe = cls(
              vae=dummy_vae,
              text_encoder=text_encoder,
              tokenizer=tokenizer,
              unet=dummy_unet,
              scheduler=scheduler,
              safety_checker=safety_checker,
              feature_extractor=feature_extractor,
              requires_safety_checker=requires_safety_checker,
          )
  
          _postload_ov(pipe, ov_unet, ov_vae_decoder)
  
      elif backend.lower() == "ipex":
          pipe = cls.from_pretrained(
              pretrained_model_name_or_path,
              scheduler=scheduler,
              **kwargs,
          )
  
          _load_ipex(pipe, device, precision)
      else:
          invalidInputError(
              False, errMsg=f"Backend{backend} not supported."
          )
  
      return pipe
  
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 1 for calling the NanoDiffusionPipeline obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrained_model_name_or_path, scheduler, device, precision, backend) and returns: pipe