code: def get_learned_conditioning(
      self: sgm.models.diffusion.DiffusionEngine,
      batch: prompt_parser.SdConditioning | list[str],
  ):
      for embedder in self.conditioner.embedders:
          embedder.ucg_rate = 0.0
  
      width = getattr(batch, "width", 1024)
      height = getattr(batch, "height", 1024)
      is_negative_prompt = getattr(batch, "is_negative_prompt", False)
      aesthetic_score = (
          shared.opts.sdxl_refiner_low_aesthetic_score
          if is_negative_prompt
          else shared.opts.sdxl_refiner_high_aesthetic_score
      )
  
      devices_args = dict(device=devices.device, dtype=devices.dtype)
  
      sdxl_conds = {
          "txt": batch,
          "original_size_as_tuple": torch.tensor(
              [height, width], **devices_args
          ).repeat(len(batch), 1),
          "crop_coords_top_left": torch.tensor(
              [shared.opts.sdxl_crop_top, shared.opts.sdxl_crop_left],
              **devices_args,
          ).repeat(len(batch), 1),
          "target_size_as_tuple": torch.tensor(
              [height, width], **devices_args
          ).repeat(len(batch), 1),
          "aesthetic_score": torch.tensor(
              [aesthetic_score], **devices_args
          ).repeat(len(batch), 1),
      }
  
      force_zero_negative_prompt = is_negative_prompt and all(
          x == "" for x in batch
      )
      c = self.conditioner(
          sdxl_conds,
          force_zero_embeddings=["txt"]
          if force_zero_negative_prompt
          else [],
      )
  
      return c
  
file_path: stable-diffusion-webui/modules/sd_models_xl.py
imports: from __future__ import annotations
  import torch
  import sgm.models.diffusion
  import sgm.modules.diffusionmodules.denoiser_scaling
  import sgm.modules.diffusionmodules.discretizer
  from modules import devices, shared, prompt_parser
label_desc: Use image node_id 1 for calling a global function with example usage: get_learned_conditioning(batch) and returns: c