class_docstr: Pipeline for text-to-image generation using PixArt-Alpha.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
  library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
  
  Args:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
      text_encoder ([`T5EncoderModel`]):
          Frozen text-encoder. PixArt-Alpha uses
          [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel), specifically the
          [t5-v1_1-xxl](https://huggingface.co/PixArt-alpha/PixArt-alpha/tree/main/t5-v1_1-xxl) variant.
      tokenizer (`T5Tokenizer`):
          Tokenizer of class
          [T5Tokenizer](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer).
      transformer ([`Transformer2DModel`]):
          A text conditioned `Transformer2DModel` to denoise the encoded image latents.
      scheduler ([`SchedulerMixin`]):
          A scheduler to be used in combination with `transformer` to denoise the encoded image latents.
class_docstr_tok: ["Pipeline","for","text-to-image","generation","using","PixArt-Alpha",".","This","model","inherits","from","[","`","DiffusionPipeline","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","the","library","implements","for","all","the","pipelines","(","such","as","downloading","or","saving",",","running","on","a","particular","device",",","etc",".",")","Args",":","vae","(","[","`","AutoencoderKL","`","]",")",":","Variational","Auto-Encoder","(","VAE",")","Model","to","encode","and","decode","images","to","and","from","latent","representations",".","text_encoder","(","[","`","T5EncoderModel","`","]",")",":","Frozen","text-encoder",".","PixArt-Alpha","uses","[","T5","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/t5","#","transformers.T5EncoderModel",")",",","specifically","the","[","t5-v1_1-xxl","]","(","https",":","\/\/huggingface.co\/PixArt-alpha\/PixArt-alpha\/tree\/main\/t5-v1_1-xxl",")","variant",".","tokenizer","(","`","T5Tokenizer","`",")",":","Tokenizer","of","class","[","T5Tokenizer","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/t5","#","transformers.T5Tokenizer",")",".","transformer","(","[","`","Transformer2DModel","`","]",")",":","A","text","conditioned","`","Transformer2DModel","`","to","denoise","the","encoded","image","latents",".","scheduler","(","[","`","SchedulerMixin","`","]",")",":","A","scheduler","to","be","used","in","combination","with","`","transformer","`","to","denoise","the","encoded","image","latents","."]
docstr: Function invoked when calling the pipeline for generation.
  
  Args:
      prompt (`str` or `List[str]`, *optional*):
          The prompt or prompts to guide the image generation. If not defined, one has to pass `prompt_embeds`.
          instead.
      negative_prompt (`str` or `List[str]`, *optional*):
          The prompt or prompts not to guide the image generation. If not defined, one has to pass
          `negative_prompt_embeds` instead. Ignored when not using guidance (i.e., ignored if `guidance_scale` is
          less than `1`).
      num_inference_steps (`int`, *optional*, defaults to 100):
          The number of denoising steps. More denoising steps usually lead to a higher quality image at the
          expense of slower inference.
      timesteps (`List[int]`, *optional*):
          Custom timesteps to use for the denoising process. If not defined, equal spaced `num_inference_steps`
          timesteps are used. Must be in descending order.
      guidance_scale (`float`, *optional*, defaults to 4.5):
          Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
          `guidance_scale` is defined as `w` of equation 2. of [Imagen
          Paper](https://arxiv.org/pdf/2205.11487.pdf). Guidance scale is enabled by setting `guidance_scale >
          1`. Higher guidance scale encourages to generate images that are closely linked to the text `prompt`,
          usually at the expense of lower image quality.
      num_images_per_prompt (`int`, *optional*, defaults to 1):
          The number of images to generate per prompt.
      height (`int`, *optional*, defaults to self.unet.config.sample_size):
          The height in pixels of the generated image.
      width (`int`, *optional*, defaults to self.unet.config.sample_size):
          The width in pixels of the generated image.
      eta (`float`, *optional*, defaults to 0.0):
          Corresponds to parameter eta (η) in the DDIM paper: https://arxiv.org/abs/2010.02502. Only applies to
          [`schedulers.DDIMScheduler`], will be ignored for others.
      generator (`torch.Generator` or `List[torch.Generator]`, *optional*):
          One or a list of [torch generator(s)](https://pytorch.org/docs/stable/generated/torch.Generator.html)
          to make generation deterministic.
      latents (`torch.FloatTensor`, *optional*):
          Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
          generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
          tensor will ge generated by sampling using the supplied random `generator`.
      prompt_embeds (`torch.FloatTensor`, *optional*):
          Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
          provided, text embeddings will be generated from `prompt` input argument.
      prompt_attention_mask (`torch.FloatTensor`, *optional*): Pre-generated attention mask for text embeddings.
      negative_prompt_embeds (`torch.FloatTensor`, *optional*):
          Pre-generated negative text embeddings. For PixArt-Alpha this negative prompt should be "". If not
          provided, negative_prompt_embeds will be generated from `negative_prompt` input argument.
      negative_prompt_attention_mask (`torch.FloatTensor`, *optional*):
          Pre-generated attention mask for negative text embeddings.
      output_type (`str`, *optional*, defaults to `"pil"`):
          The output format of the generate image. Choose between
          [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`.
      return_dict (`bool`, *optional*, defaults to `True`):
          Whether or not to return a [`~pipelines.stable_diffusion.IFPipelineOutput`] instead of a plain tuple.
      callback (`Callable`, *optional*):
          A function that will be called every `callback_steps` steps during inference. The function will be
          called with the following arguments: `callback(step: int, timestep: int, latents: torch.FloatTensor)`.
      callback_steps (`int`, *optional*, defaults to 1):
          The frequency at which the `callback` function will be called. If not specified, the callback will be
          called at every step.
      clean_caption (`bool`, *optional*, defaults to `True`):
          Whether or not to clean the caption before creating embeddings. Requires `beautifulsoup4` and `ftfy` to
          be installed. If the dependencies are not installed, the embeddings will be created from the raw
          prompt.
      use_resolution_binning (`bool` defaults to `True`):
          If set to `True`, the requested height and width are first mapped to the closest resolutions using
          `ASPECT_RATIO_1024_BIN`. After the produced latents are decoded into images, they are resized back to
          the requested resolution. Useful for generating non-square images.
  
  Examples:
  
  Returns:
      [`~pipelines.ImagePipelineOutput`] or `tuple`:
          If `return_dict` is `True`, [`~pipelines.ImagePipelineOutput`] is returned, otherwise a `tuple` is
          returned where the first element is a list with the generated images
docstr_tok: ["Function","invoked","when","calling","the","pipeline","for","generation",".","Args",":","prompt","(","`","str","`","or","`","List","[","str","]","`",",","*","optional","*",")",":","The","prompt","or","prompts","to","guide","the","image","generation",".","If","not","defined",",","one","has","to","pass","`","prompt_embeds","`",".","instead",".","negative_prompt","(","`","str","`","or","`","List","[","str","]","`",",","*","optional","*",")",":","The","prompt","or","prompts","not","to","guide","the","image","generation",".","If","not","defined",",","one","has","to","pass","`","negative_prompt_embeds","`","instead",".","Ignored","when","not","using","guidance","(","i.e.",",","ignored","if","`","guidance_scale","`","is","less","than","`","1","`",")",".","num_inference_steps","(","`","int","`",",","*","optional","*",",","defaults","to","100",")",":","The","number","of","denoising","steps",".","More","denoising","steps","usually","lead","to","a","higher","quality","image","at","the","expense","of","slower","inference",".","timesteps","(","`","List","[","int","]","`",",","*","optional","*",")",":","Custom","timesteps","to","use","for","the","denoising","process",".","If","not","defined",",","equal","spaced","`","num_inference_steps","`","timesteps","are","used",".","Must","be","in","descending","order",".","guidance_scale","(","`","float","`",",","*","optional","*",",","defaults","to","4.5",")",":","Guidance","scale","as","defined","in","[","Classifier-Free","Diffusion","Guidance","]","(","https",":","\/\/arxiv.org\/abs\/2207.12598",")",".","`","guidance_scale","`","is","defined","as","`","w","`","of","equation","2.","of","[","Imagen","Paper","]","(","https",":","\/\/arxiv.org\/pdf\/2205.11487.pdf",")",".","Guidance","scale","is","enabled","by","setting","`","guidance_scale",">","1","`",".","Higher","guidance","scale","encourages","to","generate","images","that","are","closely","linked","to","the","text","`","prompt","`",",","usually","at","the","expense","of","lower","image","quality",".","num_images_per_prompt","(","`","int","`",",","*","optional","*",",","defaults","to","1",")",":","The","number","of","images","to","generate","per","prompt",".","height","(","`","int","`",",","*","optional","*",",","defaults","to","self.unet.config.sample_size",")",":","The","height","in","pixels","of","the","generated","image",".","width","(","`","int","`",",","*","optional","*",",","defaults","to","self.unet.config.sample_size",")",":","The","width","in","pixels","of","the","generated","image",".","eta","(","`","float","`",",","*","optional","*",",","defaults","to","0.0",")",":","Corresponds","to","parameter","eta","(","\u03b7",")","in","the","DDIM","paper",":","https",":","\/\/arxiv.org\/abs\/2010.02502",".","Only","applies","to","[","`","schedulers.DDIMScheduler","`","]",",","will","be","ignored","for","others",".","generator","(","`","torch.Generator","`","or","`","List","[","torch.Generator","]","`",",","*","optional","*",")",":","One","or","a","list","of","[","torch","generator","(","s",")","]","(","https",":","\/\/pytorch.org\/docs\/stable\/generated\/torch.Generator.html",")","to","make","generation","deterministic",".","latents","(","`","torch.FloatTensor","`",",","*","optional","*",")",":","Pre-generated","noisy","latents",",","sampled","from","a","Gaussian","distribution",",","to","be","used","as","inputs","for","image","generation",".","Can","be","used","to","tweak","the","same","generation","with","different","prompts",".","If","not","provided",",","a","latents","tensor","will","ge","generated","by","sampling","using","the","supplied","random","`","generator","`",".","prompt_embeds","(","`","torch.FloatTensor","`",",","*","optional","*",")",":","Pre-generated","text","embeddings",".","Can","be","used","to","easily","tweak","text","inputs",",","*","e.g",".","*","prompt","weighting",".","If","not","provided",",","text","embeddings","will","be","generated","from","`","prompt","`","input","argument",".","prompt_attention_mask","(","`","torch.FloatTensor","`",",","*","optional","*",")",":","Pre-generated","attention","mask","for","text","embeddings",".","negative_prompt_embeds","(","`","torch.FloatTensor","`",",","*","optional","*",")",":","Pre-generated","negative","text","embeddings",".","For","PixArt-Alpha","this","negative","prompt","should","be","``","''",".","If","not","provided",",","negative_prompt_embeds","will","be","generated","from","`","negative_prompt","`","input","argument",".","negative_prompt_attention_mask","(","`","torch.FloatTensor","`",",","*","optional","*",")",":","Pre-generated","attention","mask","for","negative","text","embeddings",".","output_type","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","pil","''","`",")",":","The","output","format","of","the","generate","image",".","Choose","between","[","PIL","]","(","https",":","\/\/pillow.readthedocs.io\/en\/stable\/",")",":","`","PIL.Image.Image","`","or","`","np.array","`",".","return_dict","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","or","not","to","return","a","[","`","~pipelines.stable_diffusion.IFPipelineOutput","`","]","instead","of","a","plain","tuple",".","callback","(","`","Callable","`",",","*","optional","*",")",":","A","function","that","will","be","called","every","`","callback_steps","`","steps","during","inference",".","The","function","will","be","called","with","the","following","arguments",":","`","callback","(","step",":","int",",","timestep",":","int",",","latents",":","torch.FloatTensor",")","`",".","callback_steps","(","`","int","`",",","*","optional","*",",","defaults","to","1",")",":","The","frequency","at","which","the","`","callback","`","function","will","be","called",".","If","not","specified",",","the","callback","will","be","called","at","every","step",".","clean_caption","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","or","not","to","clean","the","caption","before","creating","embeddings",".","Requires","`","beautifulsoup4","`","and","`","ftfy","`","to","be","installed",".","If","the","dependencies","are","not","installed",",","the","embeddings","will","be","created","from","the","raw","prompt",".","use_resolution_binning","(","`","bool","`","defaults","to","`","True","`",")",":","If","set","to","`","True","`",",","the","requested","height","and","width","are","first","mapped","to","the","closest","resolutions","using","`","ASPECT_RATIO_1024_BIN","`",".","After","the","produced","latents","are","decoded","into","images",",","they","are","resized","back","to","the","requested","resolution",".","Useful","for","generating","non-square","images",".","Examples",":","Returns",":","[","`","~pipelines.ImagePipelineOutput","`","]","or","`","tuple","`",":","If","`","return_dict","`","is","`","True","`",",","[","`","~pipelines.ImagePipelineOutput","`","]","is","returned",",","otherwise","a","`","tuple","`","is","returned","where","the","first","element","is","a","list","with","the","generated","images"]
code: def __call__(
      self,
      prompt: Union[str, List[str]] = None,
      negative_prompt: str = "",
      num_inference_steps: int = 20,
      timesteps: List[int] = None,
      guidance_scale: float = 4.5,
      num_images_per_prompt: Optional[int] = 1,
      height: Optional[int] = None,
      width: Optional[int] = None,
      eta: float = 0.0,
      generator: Optional[
          Union[torch.Generator, List[torch.Generator]]
      ] = None,
      latents: Optional[torch.FloatTensor] = None,
      prompt_embeds: Optional[torch.FloatTensor] = None,
      prompt_attention_mask: Optional[torch.FloatTensor] = None,
      negative_prompt_embeds: Optional[torch.FloatTensor] = None,
      negative_prompt_attention_mask: Optional[
          torch.FloatTensor
      ] = None,
      output_type: Optional[str] = "pil",
      return_dict: bool = True,
      callback: Optional[
          Callable[[int, int, torch.FloatTensor], None]
      ] = None,
      callback_steps: int = 1,
      clean_caption: bool = True,
      use_resolution_binning: bool = True,
      **kwargs,
  ) -> Union[ImagePipelineOutput, Tuple]:
      """
      Function invoked when calling the pipeline for generation.
  
      Args:
          prompt (`str` or `List[str]`, *optional*):
              The prompt or prompts to guide the image generation. If not defined, one has to pass `prompt_embeds`.
              instead.
          negative_prompt (`str` or `List[str]`, *optional*):
              The prompt or prompts not to guide the image generation. If not defined, one has to pass
              `negative_prompt_embeds` instead. Ignored when not using guidance (i.e., ignored if `guidance_scale` is
              less than `1`).
          num_inference_steps (`int`, *optional*, defaults to 100):
              The number of denoising steps. More denoising steps usually lead to a higher quality image at the
              expense of slower inference.
          timesteps (`List[int]`, *optional*):
              Custom timesteps to use for the denoising process. If not defined, equal spaced `num_inference_steps`
              timesteps are used. Must be in descending order.
          guidance_scale (`float`, *optional*, defaults to 4.5):
              Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
              `guidance_scale` is defined as `w` of equation 2. of [Imagen
              Paper](https://arxiv.org/pdf/2205.11487.pdf). Guidance scale is enabled by setting `guidance_scale >
              1`. Higher guidance scale encourages to generate images that are closely linked to the text `prompt`,
              usually at the expense of lower image quality.
          num_images_per_prompt (`int`, *optional*, defaults to 1):
              The number of images to generate per prompt.
          height (`int`, *optional*, defaults to self.unet.config.sample_size):
              The height in pixels of the generated image.
          width (`int`, *optional*, defaults to self.unet.config.sample_size):
              The width in pixels of the generated image.
          eta (`float`, *optional*, defaults to 0.0):
              Corresponds to parameter eta (η) in the DDIM paper: https://arxiv.org/abs/2010.02502. Only applies to
              [`schedulers.DDIMScheduler`], will be ignored for others.
          generator (`torch.Generator` or `List[torch.Generator]`, *optional*):
              One or a list of [torch generator(s)](https://pytorch.org/docs/stable/generated/torch.Generator.html)
              to make generation deterministic.
          latents (`torch.FloatTensor`, *optional*):
              Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
              generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
              tensor will ge generated by sampling using the supplied random `generator`.
          prompt_embeds (`torch.FloatTensor`, *optional*):
              Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
              provided, text embeddings will be generated from `prompt` input argument.
          prompt_attention_mask (`torch.FloatTensor`, *optional*): Pre-generated attention mask for text embeddings.
          negative_prompt_embeds (`torch.FloatTensor`, *optional*):
              Pre-generated negative text embeddings. For PixArt-Alpha this negative prompt should be "". If not
              provided, negative_prompt_embeds will be generated from `negative_prompt` input argument.
          negative_prompt_attention_mask (`torch.FloatTensor`, *optional*):
              Pre-generated attention mask for negative text embeddings.
          output_type (`str`, *optional*, defaults to `"pil"`):
              The output format of the generate image. Choose between
              [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` or `np.array`.
          return_dict (`bool`, *optional*, defaults to `True`):
              Whether or not to return a [`~pipelines.stable_diffusion.IFPipelineOutput`] instead of a plain tuple.
          callback (`Callable`, *optional*):
              A function that will be called every `callback_steps` steps during inference. The function will be
              called with the following arguments: `callback(step: int, timestep: int, latents: torch.FloatTensor)`.
          callback_steps (`int`, *optional*, defaults to 1):
              The frequency at which the `callback` function will be called. If not specified, the callback will be
              called at every step.
          clean_caption (`bool`, *optional*, defaults to `True`):
              Whether or not to clean the caption before creating embeddings. Requires `beautifulsoup4` and `ftfy` to
              be installed. If the dependencies are not installed, the embeddings will be created from the raw
              prompt.
          use_resolution_binning (`bool` defaults to `True`):
              If set to `True`, the requested height and width are first mapped to the closest resolutions using
              `ASPECT_RATIO_1024_BIN`. After the produced latents are decoded into images, they are resized back to
              the requested resolution. Useful for generating non-square images.
  
      Examples:
  
      Returns:
          [`~pipelines.ImagePipelineOutput`] or `tuple`:
              If `return_dict` is `True`, [`~pipelines.ImagePipelineOutput`] is returned, otherwise a `tuple` is
              returned where the first element is a list with the generated images
      """
      if "mask_feature" in kwargs:
          deprecation_message = "The use of `mask_feature` is deprecated. It is no longer used in any computation and that doesn't affect the end results. It will be removed in a future version."
          deprecate(
              "mask_feature",
              "1.0.0",
              deprecation_message,
              standard_warn=False,
          )
      # 1. Check inputs. Raise error if not correct
      height = (
          height
          or self.transformer.config.sample_size * self.vae_scale_factor
      )
      width = (
          width
          or self.transformer.config.sample_size * self.vae_scale_factor
      )
      if use_resolution_binning:
          aspect_ratio_bin = (
              ASPECT_RATIO_1024_BIN
              if self.transformer.config.sample_size == 128
              else ASPECT_RATIO_512_BIN
          )
          orig_height, orig_width = height, width
          height, width = self.classify_height_width_bin(
              height, width, ratios=aspect_ratio_bin
          )
  
      self.check_inputs(
          prompt,
          height,
          width,
          negative_prompt,
          callback_steps,
          prompt_embeds,
          negative_prompt_embeds,
          prompt_attention_mask,
          negative_prompt_attention_mask,
      )
  
      # 2. Default height and width to transformer
      if prompt is not None and isinstance(prompt, str):
          batch_size = 1
      elif prompt is not None and isinstance(prompt, list):
          batch_size = len(prompt)
      else:
          batch_size = prompt_embeds.shape[0]
  
      device = self._execution_device
  
      # here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
      # of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
      # corresponds to doing no classifier free guidance.
      do_classifier_free_guidance = guidance_scale > 1.0
  
      # 3. Encode input prompt
      (
          prompt_embeds,
          prompt_attention_mask,
          negative_prompt_embeds,
          negative_prompt_attention_mask,
      ) = self.encode_prompt(
          prompt,
          do_classifier_free_guidance,
          negative_prompt=negative_prompt,
          num_images_per_prompt=num_images_per_prompt,
          device=device,
          prompt_embeds=prompt_embeds,
          negative_prompt_embeds=negative_prompt_embeds,
          prompt_attention_mask=prompt_attention_mask,
          negative_prompt_attention_mask=negative_prompt_attention_mask,
          clean_caption=clean_caption,
      )
      if do_classifier_free_guidance:
          prompt_embeds = torch.cat(
              [negative_prompt_embeds, prompt_embeds], dim=0
          )
          prompt_attention_mask = torch.cat(
              [negative_prompt_attention_mask, prompt_attention_mask],
              dim=0,
          )
  
      # 4. Prepare timesteps
      timesteps, num_inference_steps = retrieve_timesteps(
          self.scheduler, num_inference_steps, device, timesteps
      )
  
      # 5. Prepare latents.
      latent_channels = self.transformer.config.in_channels
      latents = self.prepare_latents(
          batch_size * num_images_per_prompt,
          latent_channels,
          height,
          width,
          prompt_embeds.dtype,
          device,
          generator,
          latents,
      )
  
      # 6. Prepare extra step kwargs. TODO: Logic should ideally just be moved out of the pipeline
      extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta)
  
      # 6.1 Prepare micro-conditions.
      added_cond_kwargs = {"resolution": None, "aspect_ratio": None}
      if self.transformer.config.sample_size == 128:
          resolution = torch.tensor([height, width]).repeat(
              batch_size * num_images_per_prompt, 1
          )
          aspect_ratio = torch.tensor([float(height / width)]).repeat(
              batch_size * num_images_per_prompt, 1
          )
          resolution = resolution.to(
              dtype=prompt_embeds.dtype, device=device
          )
          aspect_ratio = aspect_ratio.to(
              dtype=prompt_embeds.dtype, device=device
          )
  
          if do_classifier_free_guidance:
              resolution = torch.cat([resolution, resolution], dim=0)
              aspect_ratio = torch.cat(
                  [aspect_ratio, aspect_ratio], dim=0
              )
  
          added_cond_kwargs = {
              "resolution": resolution,
              "aspect_ratio": aspect_ratio,
          }
  
      # 7. Denoising loop
      num_warmup_steps = max(
          len(timesteps) - num_inference_steps * self.scheduler.order, 0
      )
  
      with self.progress_bar(total=num_inference_steps) as progress_bar:
          for i, t in enumerate(timesteps):
              latent_model_input = (
                  torch.cat([latents] * 2)
                  if do_classifier_free_guidance
                  else latents
              )
              latent_model_input = self.scheduler.scale_model_input(
                  latent_model_input, t
              )
  
              current_timestep = t
              if not torch.is_tensor(current_timestep):
                  # TODO: this requires sync between CPU and GPU. So try to pass timesteps as tensors if you can
                  # This would be a good case for the `match` statement (Python 3.10+)
                  is_mps = latent_model_input.device.type == "mps"
                  if isinstance(current_timestep, float):
                      dtype = torch.float32 if is_mps else torch.float64
                  else:
                      dtype = torch.int32 if is_mps else torch.int64
                  current_timestep = torch.tensor(
                      [current_timestep],
                      dtype=dtype,
                      device=latent_model_input.device,
                  )
              elif len(current_timestep.shape) == 0:
                  current_timestep = current_timestep[None].to(
                      latent_model_input.device
                  )
              # broadcast to batch dimension in a way that's compatible with ONNX/Core ML
              current_timestep = current_timestep.expand(
                  latent_model_input.shape[0]
              )
  
              # predict noise model_output
              noise_pred = self.transformer(
                  latent_model_input,
                  encoder_hidden_states=prompt_embeds,
                  encoder_attention_mask=prompt_attention_mask,
                  timestep=current_timestep,
                  added_cond_kwargs=added_cond_kwargs,
                  return_dict=False,
              )[0]
  
              # perform guidance
              if do_classifier_free_guidance:
                  noise_pred_uncond, noise_pred_text = noise_pred.chunk(
                      2
                  )
                  noise_pred = noise_pred_uncond + guidance_scale * (
                      noise_pred_text - noise_pred_uncond
                  )
  
              # learned sigma
              if (
                  self.transformer.config.out_channels // 2
                  == latent_channels
              ):
                  noise_pred = noise_pred.chunk(2, dim=1)[0]
              else:
                  noise_pred = noise_pred
  
              # compute previous image: x_t -> x_t-1
              latents = self.scheduler.step(
                  noise_pred,
                  t,
                  latents,
                  **extra_step_kwargs,
                  return_dict=False,
              )[0]
  
              # call the callback, if provided
              if i == len(timesteps) - 1 or (
                  (i + 1) > num_warmup_steps
                  and (i + 1) % self.scheduler.order == 0
              ):
                  progress_bar.update()
                  if callback is not None and i % callback_steps == 0:
                      step_idx = i // getattr(
                          self.scheduler, "order", 1
                      )
                      callback(step_idx, t, latents)
  
      if not output_type == "latent":
          image = self.vae.decode(
              latents / self.vae.config.scaling_factor,
              return_dict=False,
          )[0]
          if use_resolution_binning:
              image = self.resize_and_crop_tensor(
                  image, orig_width, orig_height
              )
      else:
          image = latents
  
      if not output_type == "latent":
          image = self.image_processor.postprocess(
              image, output_type=output_type
          )
  
      # Offload all models
      self.maybe_free_model_hooks()
  
      if not return_dict:
          return (image,)
  
      return ImagePipelineOutput(images=image)
  
imports: import html
  import inspect
  import re
  import urllib.parse
  from typing import Callable, List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from transformers import T5EncoderModel, T5Tokenizer
  from ...image_processor import VaeImageProcessor
  from ...models import AutoencoderKL, Transformer2DModel
  from ...schedulers import DPMSolverMultistepScheduler
  from ...utils import BACKENDS_MAPPING, deprecate, is_bs4_available, is_ftfy_available, logging, replace_example_docstring
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput
label_desc: Use image node_id 11 for calling the PixArtAlphaPipeline obj's underlying member method code with example usage: obj.__call__(prompt, negative_prompt, num_inference_steps, timesteps, guidance_scale, num_images_per_prompt, height, width, eta, generator, latents, prompt_embeds, prompt_attention_mask, negative_prompt_embeds, negative_prompt_attention_mask, output_type, return_dict, callback, callback_steps, clean_caption, use_resolution_binning) and returns: ImagePipelineOutput, image