code: def load_model_components(config, device, weight_dtype):
      tokenizers = []
      tokenizers.append(
          AutoTokenizer.from_pretrained(
              config.model,
              subfolder="tokenizer",
              revision=config.revision,
              use_fast=False,
          )
      )
      if config.xl:
          tokenizers.append(
              AutoTokenizer.from_pretrained(
                  config.model,
                  subfolder="tokenizer_2",
                  revision=config.revision,
                  use_fast=False,
              )
          )
  
      cls_text_encoders = []
      cls_text_encoders.append(
          import_model_class_from_model_name_or_path(
              config.model, config.revision
          ),
      )
      if config.xl:
          cls_text_encoders.append(
              import_model_class_from_model_name_or_path(
                  config.model,
                  config.revision,
                  subfolder="text_encoder_2",
              )
          )
  
      text_encoders = []
      text_encoders.append(
          cls_text_encoders[0].from_pretrained(
              config.model,
              subfolder="text_encoder",
              revision=config.revision,
          )
      )
      if config.xl:
          text_encoders.append(
              cls_text_encoders[1].from_pretrained(
                  config.model,
                  subfolder="text_encoder_2",
                  revision=config.revision,
              )
          )
  
      try:
          vae = AutoencoderKL.from_pretrained(
              config.model, subfolder="vae", revision=config.revision
          )
      except OSError:
          logger.warning("No VAE found. Training without VAE.")
          vae = None
  
      unet = UNet2DConditionModel.from_pretrained(
          config.model,
          subfolder="unet",
          revision=config.revision,
      )
  
      noise_scheduler = DDPMScheduler.from_pretrained(
          config.model, subfolder="scheduler"
      )
  
      # TODO: non-peft version
      if vae is not None:
          vae.requires_grad_(False)
      for _text_encoder in text_encoders:
          _text_encoder.requires_grad_(False)
      unet.requires_grad_(False)
  
      if vae is not None:
          if config.xl:
              vae.to(device, dtype=torch.float32)
          else:
              vae.to(device, dtype=weight_dtype)
      unet.to(device, dtype=weight_dtype)
      for _text_encoder in text_encoders:
          _text_encoder.to(device, dtype=weight_dtype)
  
      return tokenizers, text_encoders, vae, unet, noise_scheduler
  
imports: import hashlib
  import itertools
  import os
  from pathlib import Path
  from typing import Dict
  import torch
  from diffusers import AutoencoderKL, DDPMScheduler, DiffusionPipeline, StableDiffusionXLPipeline, UNet2DConditionModel
  from diffusers.utils.import_utils import is_xformers_available
  from packaging import version
  from tqdm import tqdm
  from transformers import AutoTokenizer, PretrainedConfig
  from autotrain import logger
  from autotrain.trainers.dreambooth.datasets import PromptDataset
label_desc: Use image node_id 8 for calling a global function with example usage: load_model_components(config, device, weight_dtype) and returns: tokenizers,  text_encoders,  vae,  unet,  noise_scheduler