code: def get_optimizer(config, unet_lora_parameters, text_lora_parameters):
      # Use 8-bit Adam for lower memory usage or to fine-tune the model in 16GB GPUs
      if config.use_8bit_adam:
          try:
              import bitsandbytes as bnb
          except ImportError:
              raise ImportError(
                  "To use 8-bit Adam, please install the bitsandbytes library: `pip install bitsandbytes`."
              )
  
          optimizer_class = bnb.optim.AdamW8bit
      else:
          optimizer_class = torch.optim.AdamW
  
      if len(text_lora_parameters) == 0:
          params_to_optimize = unet_lora_parameters
      elif len(text_lora_parameters) == 1:
          params_to_optimize = itertools.chain(
              unet_lora_parameters, text_lora_parameters[0]
          )
      elif len(text_lora_parameters) == 2:
          params_to_optimize = itertools.chain(
              unet_lora_parameters,
              text_lora_parameters[0],
              text_lora_parameters[1],
          )
      else:
          raise ValueError(
              "More than 2 text encoders are not supported."
          )
  
      optimizer = optimizer_class(
          params_to_optimize,
          lr=config.lr,
          betas=(config.adam_beta1, config.adam_beta2),
          weight_decay=config.adam_weight_decay,
          eps=config.adam_epsilon,
      )
      return optimizer
  
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 11 for calling a global function with example usage: get_optimizer(config, unet_lora_parameters, text_lora_parameters) and returns: optimizer