class_docstr: A sampler for text-to-image generation.
  :param root_dir: directory for model checkpoints.
  :param sampling_type: ["default", "fast"]
class_docstr_tok: ["A","sampler","for","text-to-image","generation",".",":","param","root_dir",":","directory","for","model","checkpoints",".",":","param","sampling_type",":","[","``","default","''",",","``","fast","''","]"]
docstr: Setup prompts & cfg scales
docstr_tok: ["Setup","prompts","&","cfg","scales"]
code: def preprocess(
      self,
      prompt: str,
      bsz: int,
  ):
      """Setup prompts & cfg scales"""
      prompts_batch = [prompt for _ in range(bsz)]
  
      prior_cf_scales_batch = [self._prior_cf_scale] * len(
          prompts_batch
      )
      prior_cf_scales_batch = torch.tensor(
          prior_cf_scales_batch, device="cuda"
      )
  
      decoder_cf_scales_batch = [self._decoder_cf_scale] * len(
          prompts_batch
      )
      decoder_cf_scales_batch = torch.tensor(
          decoder_cf_scales_batch, device="cuda"
      )
  
      """ Get CLIP text feature """
      clip_model = self._clip
      tokenizer = self._tokenizer
      max_txt_length = self._prior.model.text_ctx
  
      tok, mask = tokenizer.padded_tokens_and_mask(
          prompts_batch, max_txt_length
      )
      cf_token, cf_mask = tokenizer.padded_tokens_and_mask(
          [""], max_txt_length
      )
      if not (cf_token.shape == tok.shape):
          cf_token = cf_token.expand(tok.shape[0], -1)
          cf_mask = cf_mask.expand(tok.shape[0], -1)
  
      tok = torch.cat([tok, cf_token], dim=0)
      mask = torch.cat([mask, cf_mask], dim=0)
  
      tok, mask = tok.to(device="cuda"), mask.to(device="cuda")
      txt_feat, txt_feat_seq = clip_model.encode_text(tok)
  
      return (
          prompts_batch,
          prior_cf_scales_batch,
          decoder_cf_scales_batch,
          txt_feat,
          txt_feat_seq,
          tok,
          mask,
      )
  
file_path: StableDiffusion/ldm/modules/karlo/kakao/sampler.py
imports: from typing import Iterator
  import torch
  import torchvision.transforms.functional
  from torchvision.transforms import InterpolationMode
  from .template import BaseSampler, CKPT_PATH
label_desc: Use image node_id 3 for calling the T2ISampler obj's underlying member method code with example usage: obj.preprocess(prompt, bsz) and returns: prompts_batch,  prior_cf_scales_batch,  decoder_cf_scales_batch,  txt_feat,  txt_feat_seq,  tok,  mask