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","''","]"]
code: def __call__(
      self,
      prompt: str,
      bsz: int,
      progressive_mode=None,
  ) -> Iterator[torch.Tensor]:
      assert progressive_mode in ("loop", "stage", "final")
      with torch.no_grad(), torch.cuda.amp.autocast():
          (
              prompts_batch,
              prior_cf_scales_batch,
              decoder_cf_scales_batch,
              txt_feat,
              txt_feat_seq,
              tok,
              mask,
          ) = self.preprocess(
              prompt,
              bsz,
          )
  
          """ Transform CLIP text feature into image feature """
          img_feat = self._prior(
              txt_feat,
              txt_feat_seq,
              mask,
              prior_cf_scales_batch,
              timestep_respacing=self._prior_sm,
          )
  
          """ Generate 64x64px images """
          images_64_outputs = self._decoder(
              txt_feat,
              txt_feat_seq,
              tok,
              mask,
              img_feat,
              cf_guidance_scales=decoder_cf_scales_batch,
              timestep_respacing=self._decoder_sm,
          )
  
          images_64 = None
          for k, out in enumerate(images_64_outputs):
              images_64 = out
              if progressive_mode == "loop":
                  yield torch.clamp(out * 0.5 + 0.5, 0.0, 1.0)
          if progressive_mode == "stage":
              yield torch.clamp(out * 0.5 + 0.5, 0.0, 1.0)
  
          images_64 = torch.clamp(images_64, -1, 1)
  
          """ Upsample 64x64 to 256x256 """
          images_256 = TVF.resize(
              images_64,
              [256, 256],
              interpolation=InterpolationMode.BICUBIC,
              antialias=True,
          )
          images_256_outputs = self._sr_64_256(
              images_256, timestep_respacing=self._sr_sm
          )
  
          for k, out in enumerate(images_256_outputs):
              images_256 = out
              if progressive_mode == "loop":
                  yield torch.clamp(out * 0.5 + 0.5, 0.0, 1.0)
          if progressive_mode == "stage":
              yield torch.clamp(out * 0.5 + 0.5, 0.0, 1.0)
  
      yield torch.clamp(images_256 * 0.5 + 0.5, 0.0, 1.0)
  
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 4 for calling the T2ISampler obj's underlying member method code with example usage: obj.__call__(prompt, bsz, progressive_mode) without return types