
    
3j                        S SK r S SKJr  S SKrS SKrS SKrS SKJ	r
  S SKJrJrJrJr  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJrJrJ r J!r!  SSK"J#r#  SSK$J%r%  SSK&J'r'  \" 5       (       a  S SK(J)s  J*r+  Sr,OSr,\ RZ                  " \.5      r/\" 5       (       a  S SK0r0\ RZ                  " \.5      r/Sr1S r2S r3S r4 " S S\%\5      r5g)    N)Callable)
functional)CLIPTextModelCLIPTokenizer"Qwen2_5_VLForConditionalGenerationQwen2VLProcessor   )MultiPipelineCallbacksPipelineCallback)VaeImageProcessor)KandinskyLoraLoaderMixin)AutoencoderKL)Kandinsky5Transformer3DModel)FlowMatchEulerDiscreteScheduler)is_ftfy_availableis_torch_xla_availableloggingreplace_example_docstring)randn_tensor   )DiffusionPipeline   )KandinskyImagePipelineOutputTFa<  
    Examples:

        ```python
        >>> import torch
        >>> from diffusers import Kandinsky5T2IPipeline

        >>> # Available models:
        >>> # kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers
        >>> # kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers

        >>> model_id = "kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers"
        >>> pipe = Kandinsky5T2IPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
        >>> pipe = pipe.to("cuda")

        >>> prompt = "A cat and a dog baking a cake together in a kitchen."

        >>> output = pipe(
        ...     prompt=prompt,
        ...     negative_prompt="",
        ...     height=1024,
        ...     width=1024,
        ...     num_inference_steps=50,
        ...     guidance_scale=3.5,
        ... ).frames[0]
        ```
c                     [        5       (       a  [        R                  " U 5      n [        R                  " [        R                  " U 5      5      n U R                  5       $ )z
Copied from https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan.py

Clean text using ftfy if available and unescape HTML entities.
)r   ftfyfix_texthtmlunescapestriptexts    o/home/wildlama/miniconda3/lib/python3.13/site-packages/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.pybasic_cleanr#   W   s>     }}T"==t,-D::<    c                 V    [         R                  " SSU 5      n U R                  5       n U $ )z
Copied from https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan.py

Normalize whitespace in text by replacing multiple spaces with single space.
z\s+ )resubr   r    s    r"   whitespace_cleanr)   c   s&     66&#t$D::<DKr$   c                 .    [        [        U 5      5      n U $ )z
Copied from https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan.py

Apply both basic cleaning and whitespace normalization to prompts.
)r)   r#   r    s    r"   prompt_cleanr+   n   s     K-.DKr$   c            +         ^  \ rS rSrSrSr/ SQrS\S\S\	S\
S	\S
\S\4U 4S jjr   S8S\\   S\R$                  S-  S\S\R(                  S-  4S jjr  S9S\\\   -  S\R$                  S-  S\R(                  S-  4S jjr    S:S\\\   -  S\S\S\R$                  S-  S\R(                  S-  4
S jjr        S;S jr       S<S\S\S\S\S\R(                  S-  S\R$                  S-  S\R2                  \\R2                     -  S-  S\R4                  S-  S \R4                  4S! jjr\S" 5       r\S# 5       r\S$ 5       r\R@                  " 5       \!" \"5      SSSSS%S&SSSSSSSSSS'S(SS/S4S\\\   -  S)\\\   -  S-  S\S\S*\S+\#S\S-  S\R2                  \\R2                     -  S-  S\R4                  S-  S,\R4                  S-  S-\R4                  S-  S.\R4                  S-  S/\R4                  S-  S0\R4                  S-  S1\R4                  S-  S2\S-  S3\$S4\%\\S/\&\'-  4   S-  S5\\   S\4(S6 jj5       5       r(S7r)U =r*$ )=Kandinsky5T2IPipelinex   a1  
Pipeline for text-to-image generation using Kandinsky 5.0.

This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).

Args:
    transformer ([`Kandinsky5Transformer3DModel`]):
        Conditional Transformer to denoise the encoded image latents.
    vae ([`AutoencoderKL`]):
        Variational Auto-Encoder Model [black-forest-labs/FLUX.1-dev
        (vae)](https://huggingface.co/black-forest-labs/FLUX.1-dev) to encode and decode videos to and from latent
        representations.
    text_encoder ([`Qwen2_5_VLForConditionalGeneration`]):
        Frozen text-encoder [Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct).
    tokenizer ([`AutoProcessor`]):
        Tokenizer for Qwen2.5-VL.
    text_encoder_2 ([`CLIPTextModel`]):
        Frozen [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel),
        specifically the [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) variant.
    tokenizer_2 ([`CLIPTokenizer`]):
        Tokenizer for CLIP.
    scheduler ([`FlowMatchEulerDiscreteScheduler`]):
        A scheduler to be used in combination with `transformer` to denoise the encoded image latents.
z.text_encoder->text_encoder_2->transformer->vae)latentsprompt_embeds_qwenprompt_embeds_clipnegative_prompt_embeds_qwennegative_prompt_embeds_cliptransformervaetext_encoder	tokenizertext_encoder_2tokenizer_2	schedulerc           
         > [         TU ]  5         U R                  UUUUUUUS9  SU l        SU l        SU l        [        U R
                  S9U l        / SQU l        g )N)r4   r5   r6   r7   r8   r9   r:   z<|im_start|>system
You are a promt engineer. Describe the image by detailing the color, shape, size, texture, quantity, text, spatial relationships of the objects and background:<|im_end|>
<|im_start|>user
{}<|im_end|>)      )vae_scale_factor))   r?   )    )rA   r@   )      )rC   rB   )    )rE   rD   )	super__init__register_modulesprompt_template prompt_template_encode_start_idxvae_scale_factor_spatialr   image_processorresolutions)	selfr4   r5   r6   r7   r8   r9   r:   	__class__s	           r"   rG   Kandinsky5T2IPipeline.__init__   sn     	#%)# 	 	
  02-()%0$B_B_`wr$   N   promptdevicemax_sequence_lengthdtypec           
         U=(       d    U R                   nU=(       d    U R                  R                  nU Vs/ s H  oPR                  R	                  U5      PM     nnU R
                  U-   nU R                  USSSSS9S   nUR                  S   U:  a  [        U5       Hs  u  pX   U R
                  S nU R                  R                  XS-
  S 5      n[        U5      S	:  d  MG  U
S[        U5      *  Xi'   [        R                  S
U SU 35        Mu     U R                  USSUSSSS9R                  U5      nU R                  US   SSS9S   S   SS2U R
                  S24   nUS   SS2U R
                  S24   n[        R                  " UR!                  S5      S	S9n["        R$                  " USS	S9R                  [        R&                  S9nUR                  U5      U4$ s  snf )a  
Encode prompt using Qwen2.5-VL text encoder.

This method processes the input prompt through the Qwen2.5-VL model to generate text embeddings suitable for
image generation.

Args:
    prompt list[str]: Input list of prompts
    device (torch.device): Device to run encoding on
    max_sequence_length (int): Maximum sequence length for tokenization
    dtype (torch.dtype): Data type for embeddings

Returns:
    tuple[torch.Tensor, torch.Tensor]: Text embeddings and cumulative sequence lengths
Nptlongest)r!   imagesvideosreturn_tensorspadding	input_idsr   r   zXThe following part of your input was truncated because `max_sequence_length` is set to  z	 tokens: T)r!   rY   rZ   
max_length
truncationr[   r\   )r]   return_dictoutput_hidden_stateshidden_statesattention_maskr   )dim)r   r   )value)rU   )_execution_devicer6   rU   rI   formatrJ   r7   shape	enumeratedecodelenloggerwarningtotorchcumsumsumFpadint32)rN   rR   rS   rT   rU   p
full_textsmax_allowed_lenuntruncated_idsir!   tokensremoved_textinputsembedsre   
cu_seqlenss                    r"   _encode_prompt_qwen)Kandinsky5T2IPipeline._encode_prompt_qwen   s1   , 14110**00>DEf**11!4f
E??BUU.. ) 
    $6$Z0(+D,Q,QTVW#~~44VRS<S<U5VW|$q($()=C,=+=$>JMNN/0	,I 1 &   
 "V* 	 ""[)!% # 
 	 	  !$"G"G"II	K
   01!T5Z5Z5\2\]\\."4"4Q"7Q?
UU:vQ7:::M
yy++S Fs   $G*c           	          U=(       d    U R                   nU=(       d    U R                  R                  nU R                  USSSSSS9R	                  U5      nU R                  " S0 UD6S   nUR	                  U5      $ )a  
Encode prompt using CLIP text encoder.

This method processes the input prompt through the CLIP model to generate pooled embeddings that capture
semantic information.

Args:
    prompt (str | list[str]): Input prompt or list of prompts
    device (torch.device): Device to run encoding on
    dtype (torch.dtype): Data type for embeddings

Returns:
    torch.Tensor: Pooled text embeddings from CLIP
M   Tr`   rW   )r`   ra   add_special_tokensr\   r[   pooler_output )rh   r8   rU   r9   rp   )rN   rR   rS   rU   r~   pooled_embeds         r"   _encode_prompt_clip)Kandinsky5T2IPipeline._encode_prompt_clip   s    ( 14112,,22!!#  " 
 "V* 	 **4V4_Eu%%r$   r   num_images_per_promptc                    U=(       d    U R                   nU=(       d    U R                  R                  n[        U[        5      (       d  U/n[        U5      nU Vs/ s H  n[        U5      PM     nnU R                  UUUUS9u  pU R                  UUUS9n
UR                  SUS5      nUR                  Xb-  SUR                  S   5      nU
R                  SUS5      n
U
R                  Xb-  S5      n
U	R                  5       nUR                  U5      n[        R                  " [        R                   " S/U[        R"                  S9UR%                  S5      /5      nXU4$ s  snf )a0  
Encodes a single prompt (positive or negative) into text encoder hidden states.

This method combines embeddings from both Qwen2.5-VL and CLIP text encoders to create comprehensive text
representations for image generation.

Args:
    prompt (`str` or `list[str]`):
        Prompt to be encoded.
    num_images_per_prompt (`int`, *optional*, defaults to 1):
        Number of images to generate per prompt.
    max_sequence_length (`int`, *optional*, defaults to 512):
        Maximum sequence length for text encoding. Must be less than 1024
    device (`torch.device`, *optional*):
        Torch device.
    dtype (`torch.dtype`, *optional*):
        Torch dtype.

Returns:
    tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
        - Qwen text embeddings of shape (batch_size * num_images_per_prompt, sequence_length, embedding_dim)
        - CLIP pooled embeddings of shape (batch_size * num_images_per_prompt, clip_embedding_dim)
        - Cumulative sequence lengths (`cu_seqlens`) for Qwen embeddings of shape (batch_size *
          num_images_per_prompt + 1,)
)rR   rS   rT   rU   )rR   rS   rU   r   r^   r   rS   rU   )rh   r6   rU   
isinstancelistrm   r+   r   r   repeatviewrj   diffrepeat_interleaverq   cattensorrv   rr   )rN   rR   r   rT   rS   rU   
batch_sizerw   r0   prompt_cu_seqlensr1   original_lengthsrepeated_lengthsrepeated_cu_seqlenss                 r"   encode_prompt#Kandinsky5T2IPipeline.encode_prompt!  s   B 14110**00&$''XF[
+126a,q/62 150H0H 3	 1I 1
- "55 6 
 066$a
 044.4F4L4LR4P

 066$a
 044Z5WY[\ -113+==!
 $ii\\1#fEKK@BRBYBYZ[B\]
 "7JJJa 3s   E#c                 r  ^  Ub  US:  a  [        S5      eXC4T R                  ;  aV  SR                  T R                   VVs/ s H  u  pSU SU S3PM     snn5      n[        R	                  SU SU S	U S
35        UbX  [        U 4S jU 5       5      (       d>  [        ST R                   SU Vs/ s H  nUT R                  ;  d  M  UPM     sn 35      eUc  Uc  U	b  Ub  Ub  U	c  [        S5      eUc  Uc  U
b  Ub  Ub  U
c  [        S5      eUc  Uc  [        S5      eUbA  [        U[        5      (       d,  [        U[        5      (       d  [        S[        U5       35      eUbC  [        U[        5      (       d-  [        U[        5      (       d  [        S[        U5       35      egggs  snnf s  snf )a  
Validate input parameters for the pipeline.

Args:
    prompt: Input prompt
    negative_prompt: Negative prompt for guidance
    height: Image height
    width: Image width
    prompt_embeds_qwen: Pre-computed Qwen prompt embeddings
    prompt_embeds_clip: Pre-computed CLIP prompt embeddings
    negative_prompt_embeds_qwen: Pre-computed Qwen negative prompt embeddings
    negative_prompt_embeds_clip: Pre-computed CLIP negative prompt embeddings
    prompt_cu_seqlens: Pre-computed cumulative sequence lengths for Qwen positive prompt
    negative_prompt_cu_seqlens: Pre-computed cumulative sequence lengths for Qwen negative prompt
    callback_on_step_end_tensor_inputs: Callback tensor inputs

Raises:
    ValueError: If inputs are invalid
Nr?   z*max_sequence_length must be less than 1024,()z'`height` and `width` have to be one of z
, but are z and z(. Dimensions will be resized accordinglyc              3   @   >#    U  H  oTR                   ;   v   M     g 7f)N)_callback_tensor_inputs).0krN   s     r"   	<genexpr>5Kandinsky5T2IPipeline.check_inputs.<locals>.<genexpr>  s      F
7Y!---7Ys   z2`callback_on_step_end_tensor_inputs` has to be in z, but found zuIf any of `prompt_embeds_qwen`, `prompt_embeds_clip`, or `prompt_cu_seqlens` is provided, all three must be provided.zIf any of `negative_prompt_embeds_qwen`, `negative_prompt_embeds_clip`, or `negative_prompt_cu_seqlens` is provided, all three must be provided.zProvide either `prompt` or `prompt_embeds_qwen` (and corresponding `prompt_embeds_clip` and `prompt_cu_seqlens`). Cannot leave all undefined.z2`prompt` has to be of type `str` or `list` but is z;`negative_prompt` has to be of type `str` or `list` but is )
ValueErrorrM   joinrn   ro   allr   r   strr   type)rN   rR   negative_promptheightwidthr0   r1   r2   r3   r   negative_prompt_cu_seqlens"callback_on_step_end_tensor_inputsrT   whresolutions_strr   s   `                r"   check_inputs"Kandinsky5T2IPipeline.check_inputs|  s\   F */BT/IIJJ?$"2"22!hhAQAQ'RAQ!A3as!AQ'RSONN9/9J*U[T\\abgah  iQ  R .9# F
7YF
 C
 C
 DTEaEaDbbn  |^  pH  |^vw  bc  ko  kG  kG  bGpq  |^  pH  oI  J 
 )-?-KO`Ol!)-?-GK\Kd 2  (3*6)5 ,3.6-5 2  >08 ` 
 z&#'>'>zRXZ^G_G_QRVW]R^Q_`aa&?C00OUY9Z9ZZ[_`o[pZqrss :[0 '[ (S pHs   F.
1F4	F4r?   r   num_channels_latentsr   r   	generatorr/   returnc	                 "   Ub  UR                  XeS9$ US[        U5      U R                  -  [        U5      U R                  -  U4n	[        U[        5      (       a*  [        U5      U:w  a  [        S[        U5       SU S35      e[        XXeS9nU$ )aG  
Prepare initial latent variables for text-to-image generation.

This method creates random noise latents

Args:
    batch_size (int): Number of images to generate
    num_channels_latents (int): Number of channels in latent space
    height (int): Height of generated image
    width (int): Width of generated image
    dtype (torch.dtype): Data type for latents
    device (torch.device): Device to create latents on
    generator (torch.Generator): Random number generator
    latents (torch.Tensor): Pre-existing latents to use

Returns:
    torch.Tensor: Prepared latent tensor
r   r   z/You have passed a list of generators of length z+, but requested an effective batch size of z@. Make sure the batch size matches the length of the generators.)r   rS   rU   )rp   intrK   r   r   rm   r   r   )
rN   r   r   r   r   rU   rS   r   r/   rj   s
             r"   prepare_latents%Kandinsky5T2IPipeline.prepare_latents  s    : ::V:99 K4888J$777 
 i&&3y>Z+GA#i.AQ R&<'gi  u&Vr$   c                     U R                   $ )z%Get the current guidance scale value.)_guidance_scalerN   s    r"   guidance_scale$Kandinsky5T2IPipeline.guidance_scale  s     ###r$   c                     U R                   $ )z&Get the number of denoising timesteps.)_num_timestepsr   s    r"   num_timesteps#Kandinsky5T2IPipeline.num_timesteps  s     """r$   c                     U R                   $ )z)Check if generation has been interrupted.)
_interruptr   s    r"   	interruptKandinsky5T2IPipeline.interrupt  s     r$   2   g      @pilTr   num_inference_stepsr   r0   r1   r2   r3   r   r   output_typerb   callback_on_step_endr   c                     [        U[        [        45      (       a  UR                  nU R	                  UUUUU
UUUUUUUS9  XC4U R
                  ;  aW  U R
                  [        R                  " U R
                   Vs/ s H  n[        US   US   -  XC-  -
  5      PM     sn5         u  pCX`l	        SU l
        U R                  nU R                  R                  nUb  [        U[        5      (       a  SnU/nO3Ub!  [        U[        5      (       a  [!        U5      nOU
R"                  S   nU
c  U R%                  UUUUUS9u  pnU R&                  S:  a  Uc  Sn[        U[        5      (       a  Ub  U/[!        U5      -  OU/nO<[!        U5      [!        U5      :w  a$  [)        S	[!        U5       S
[!        U5       S35      eUc  U R%                  UUUUUS9u  pnU R*                  R-                  UUS9  U R*                  R.                  nU R                  R0                  R2                  nU R5                  UU-  UUUUUUU	S9n	[6        R8                  " SUS9[6        R8                  " X0R:                  -  S-  US9[6        R8                  " X@R:                  -  S-  US9/n[6        R8                  " UR=                  5       R?                  5       RA                  5       US9nUb?  [6        R8                  " UR=                  5       R?                  5       RA                  5       US9OSn/ SQnSn[!        U5      XPR*                  RB                  -  -
  n [!        U5      U l"        U RG                  US9 n![I        U5       GH.  u  nn"U RJ                  (       a  M  U"RM                  S5      RO                  UU-  5      n#U R                  U	RQ                  U5      U
RQ                  U5      URQ                  U5      U#RQ                  U5      UUUUSS9	RR                  n$U R&                  S:  ak  Ubh  U R                  U	RQ                  U5      URQ                  U5      URQ                  U5      U#RQ                  U5      UUUUSS9	RR                  n%U%UU$U%-
  -  -   n$U R*                  RU                  U$SS2SS24   U"U	SS9S   n	Ub  0 n&U H  n'[W        5       U'   U&U''   M     U" U UU"U&5      n(U(RY                  SU	5      n	U(RY                  SU
5      n
U(RY                  SU5      nU(RY                  SU5      nU(RY                  SU5      nU[!        U5      S-
  :X  d)  US-   U :  a0  US-   U R*                  RB                  -  S:X  a  U!R[                  5         [\        (       d  GM  [^        R`                  " 5         GM1     SSS5        U	SS2SS2SS2SS2SU24   n	US:w  a  U	RQ                  U Rb                  R                  5      n	U	Re                  UUSX0R:                  -  X@R:                  -  U5      n	U	Rg                  SSSSSS5      n	U	Re                  UU-  UX0R:                  -  X@R:                  -  5      n	XRb                  R0                  Rh                  -  n	U Rb                  Rk                  U	5      RR                  n)U Rl                  Ro                  U)US9n)OU	n)U Rq                  5         U(       d  U)4$ [s        U)S9$ s  snf ! , (       d  f       GNM= f)a
  
The call function to the pipeline for text-to-image generation.

Args:
    prompt (`str` or `list[str]`, *optional*):
        The prompt or prompts to guide the image generation. If not defined, pass `prompt_embeds` instead.
    negative_prompt (`str` or `list[str]`, *optional*):
        The prompt or prompts to avoid during image generation. If not defined, pass `negative_prompt_embeds`
        instead. Ignored when not using guidance (`guidance_scale` < `1`).
    height (`int`, defaults to `1024`):
        The height in pixels of the generated image.
    width (`int`, defaults to `1024`):
        The width in pixels of the generated image.
    num_inference_steps (`int`, defaults to `50`):
        The number of denoising steps.
    guidance_scale (`float`, defaults to `5.0`):
        Guidance scale as defined in classifier-free guidance.
    num_images_per_prompt (`int`, *optional*, defaults to 1):
        The number of images to generate per prompt.
    generator (`torch.Generator` or `list[torch.Generator]`, *optional*):
        A torch generator to make generation deterministic.
    latents (`torch.Tensor`, *optional*):
        Pre-generated noisy latents.
    prompt_embeds_qwen (`torch.Tensor`, *optional*):
        Pre-generated Qwen text embeddings.
    prompt_embeds_clip (`torch.Tensor`, *optional*):
        Pre-generated CLIP text embeddings.
    negative_prompt_embeds_qwen (`torch.Tensor`, *optional*):
        Pre-generated Qwen negative text embeddings.
    negative_prompt_embeds_clip (`torch.Tensor`, *optional*):
        Pre-generated CLIP negative text embeddings.
    prompt_cu_seqlens (`torch.Tensor`, *optional*):
        Pre-generated cumulative sequence lengths for Qwen positive prompt.
    negative_prompt_cu_seqlens (`torch.Tensor`, *optional*):
        Pre-generated cumulative sequence lengths for Qwen negative prompt.
    output_type (`str`, *optional*, defaults to `"pil"`):
        The output format of the generated image.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether or not to return a [`KandinskyImagePipelineOutput`].
    callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *optional*):
        A function that is called at the end of each denoising step.
    callback_on_step_end_tensor_inputs (`List`, *optional*):
        The list of tensor inputs for the `callback_on_step_end` function.
    max_sequence_length (`int`, defaults to `512`):
        The maximum sequence length for text encoding.

Examples:

Returns:
    [`~KandinskyImagePipelineOutput`] or `tuple`:
        If `return_dict` is `True`, [`KandinskyImagePipelineOutput`] is returned, otherwise a `tuple` is
        returned where the first element is a list with the generated images.
)rR   r   r   r   r0   r1   r2   r3   r   r   r   rT   r   r   FN)rR   r   rT   rS   rU         ? z9`negative_prompt` must have same length as `prompt`. Got z vs .)rS   )r   r   r   r   rU   rS   r   r/   r   )r   r   r   )totalT)	rd   encoder_hidden_statespooled_projectionstimestepvisual_rope_postext_rope_posscale_factorsparse_paramsrb   )rb   r/   r0   r1   r2   r3   latent   r	      )r   )image):r   r   r
   tensor_inputsr   rM   npargminabsr   r   rh   r4   rU   r   r   rm   rj   r   r   r   r:   set_timesteps	timestepsconfigin_visual_dimr   rq   arangerK   r   maxitemorderr   progress_barrk   r   	unsqueezer   rp   samplesteplocalspopupdateXLA_AVAILABLExm	mark_stepr5   reshapepermutescaling_factorrl   rL   postprocessmaybe_free_model_hooksr   )*rN   rR   r   r   r   r   r   r   r   r/   r0   r1   r2   r3   r   r   r   rb   r   r   rT   r{   rS   rU   r   r   r   r   r   negative_text_rope_posr   r   num_warmup_stepsr   tr   pred_velocityuncond_pred_velocitycallback_kwargsr   callback_outputsr   s*                                             r"   __call__Kandinsky5T2IPipeline.__call__  s@   \ *-=?U,VWW1E1S1S.+11(C(C/'A/Q 3 	 	
 ?$"2"22 ,,		$JZJZ[JZQ3!qt?@JZ[\ME  .''  && *VS"9"9JXFJvt$<$<VJ+11!4J %HLHZHZ&;$7 I[ IE4E $&"$/3//EKEW?"3c&k"A^m]n_%V4 OPSTcPdOeeijmntjuivvwx  +2&&..C,?%# '  e+Jd 	$$%8$HNN,,	  $//66DD&&!$99!5 ' 	
 LL6*LL#@#@@AEfULL"?"??1DVT
 %6%;%;%=%A%A%C%H%H%JSYZ *5 LL388:>>@EEGPVW 	 '  y>,?..BVBV,VV!)n%89\!),1>>;;q>00>S1ST !% 0 0")**U"3*<*?*?*F'9'<'<U'C%[[/$3"/!-"/ $ !1 
! &  &&,1L1X+/+;+;&-jj&7.I.L.LU.S+F+I+I%+P!)U!3(7&<%1&3$( ,< 
, f ) %9>]]qMq;r$rM..--mAqD.A1g[`-abcd'3&(O?-3Xa[* @';D!Q'X$.229gFG)9)=)=>RTf)g&)9)=)=>RTf)g&2B2F2F57R3/ 3C2F2F57R3/ I**A9I/IqSTuX\XfXfXlXlNlpqNq '') =LLNq - :x !Q1&;';&;;< ("jj0Goo%777666$G ooaAq!Q7Goo22$777666	G  > >>GHHOOG,33E((44U4TEE 	##%8O+%88u \v :9s   <#[)
)H [.[..
[=)r   r   r   rL   rI   rJ   rM   rK   )NrQ   N)NN)r   rQ   NN)NNNNNNNN)   r?   r?   NNNN)+__name__
__module____qualname____firstlineno____doc__model_cpu_offload_seqr   r   r   r   r   r   r   r   rG   r   r   rq   rS   r   rU   r   r   r   r   	GeneratorTensorr   propertyr   r   r   no_gradr   EXAMPLE_DOC_STRINGfloatboolr   r   r
   r  __static_attributes____classcell__)rO   s   @r"   r-   r-   x   sM   4 Mx1x x 9	x
 $x &x #x 3x@ '+#&$(B,S	B, t#B, !	B,
 {{T!B,N '+$(	"&d3i"& t#"& {{T!	"&N &'#&&*$(YKd3iYK  #YK !	YK
 t#YK {{T!YKB  $($(#'+/ Wtx %'$(&*DH'+00 "0 	0
 0 {{T!0 t#0 ??T%//%::TA0 $0 
0d $ $ # #   ]]_12 #'26#% #,-DH'+2626;?;?15:>"' mq9B#&+X9d3iX9 tCy4/X9 	X9
 X9 !X9 X9  #TzX9 ??T%//%::TAX9 $X9 "LL4/X9 "LL4/X9 &+\\D%8X9 &+\\D%8X9 !<<$.X9  %*LL4$7!X9" 4Z#X9$ %X9& 'S$'79ILb9b'bcfjj'X9( -1I)X9* !+X9 3 X9r$   r-   )6r   typingr   numpyr   regexr'   rq   torch.nnr   rt   transformersr   r   r   r   	callbacksr
   r   rL   r   loadersr   modelsr   models.transformersr   
schedulersr   utilsr   r   r   r   utils.torch_utilsr   pipeline_utilsr   pipeline_outputr   torch_xla.core.xla_modelcore	xla_modelr   r   
get_loggerr  rn   r   r  r#   r)   r+   r-   r   r$   r"   <module>r%     s         $ k k A 0 / # ? 9  . . 9 ))MM			H	% 
		H	% :	x
9-/G x
9r$   