
    i                        d dl Z d dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
mZ d dlZd dlZd dlmZmZmZ d dlmZ d dlmZ d dlmZmZmZ d dlmZmZ d dlmZ d d	lm Z  d d
l!m"Z" d dl#m$Z$ d dl%m&Z&m'Z' d dl(m)Z) dZ*ddgddgddgddgddgddgddgdZ+ddgddgddgddgddgdd gddgd dgddgddgddgddgddgd!Z,i d"dd#gd$d%d&gd'd%d(gd)d*d+gd,d*d-gd.d/d0gd1d2d3gd4d2d5gd6d7d8gd9d:d;gd<d=d>gd?d@d@gdAd>d=gdBdCdDgdEd;d:gdFd8d7gdGdHdIgd5d2gd3d2gd-d*gd+d*gd(d%gd&d%gd#dgdJZ-e+e,e-dKZ. e&j^                  e0      Z1 G dL dM      Z2dNZ3 G dO dPe eee      Z4y)Q    N)CallableDictListOptionalUnion)AutoTokenizerGemmaTokenizerFastT5TokenizerFast)T5GemmaEncoder)PixArtImageProcessor)FromSingleFileMixinLoraLoaderMixinTextualInversionLoaderMixin)AutoencoderDCAutoencoderKL)PRXTransformer2DModel)DiffusionPipeline)PRXPipelineOutput)FlowMatchEulerDiscreteScheduler)loggingreplace_example_docstring)randn_tensor      i`     i@     i      )z0.460.60.781.01.291.67z2.2i  i  i  i  i  i`  i  i@  i  i   )z0.50.57r   0.68r   z0.88r    1.13r!   1.46r"   1.75z2.0z0.49i  z0.52i  i  z0.53i`  r#   i   i@  z0.59i   z0.62i   i   z0.67i@  i  r$   i  r   i  i  z0.83i  i`  z0.94i  i   r       z1.06r%   i@  i  z1.21r!   z1.37i  i`  )r&   z1.5z1.71r'   z1.87z1.91z2.05)r   r   r(   c                   &    e Zd ZdZd ZdedefdZy)TextPreprocessorz+Text preprocessing utility for PRXPipeline.c                 8    t        j                  d      | _        y)zInitialize text preprocessor.u6   [#®•©™&@·º½¾¿¡§~\)\(\]\[\}\{\|\\\/\*]{1,}N)recompilebad_punct_regexselfs    n/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/diffusers/pipelines/prx/pipeline_prx.py__init__zTextPreprocessor.__init__o   s    !zz 
    textreturnc                 	   t        |      }t        j                  |      }|j                         j	                         }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  d	d|      }t        j                  d
d|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  dd|      }t        j                  | j                  d|      }t        j                  dd|      }t        j                  d       }t        t        j                  ||            d!kD  rt        j                  |d|      }t        j                  |      }t        j                  t        j                  |            }|j                         }t        j                  d"d|      }t        j                  d#d|      }t        j                  d$d|      }t        j                  d%d|      }t        j                  d&d|      }t        j                  d'd|      }t        j                  d(d|      }t        j                  d)d|      }t        j                  d*d|      }t        j                  d+d|      }t        j                  d,d-|      }t        j                  d.d/|      }t        j                  d0d|      }|j                          t        j                  d1d2|      }t        j                  d3d|      }t        j                  d4d|      }t        j                  d5d|      }|j                         S )6z5Clean text using comprehensive text processing logic.z<person>personzo\b((?:https?|www):(?:\/{1,3}|[a-zA-Z0-9%])|[a-zA-Z0-9.\-]+[.](?:com|co|ru|net|org|edu|gov|it)[\w/-]*\b\/?(?!@)) z
@[\w\d]+\bz[\u31c0-\u31ef]+z[\u31f0-\u31ff]+z[\u3200-\u32ff]+z[\u3300-\u33ff]+z[\u3400-\u4dbf]+z[\u4dc0-\u4dff]+z[\u4e00-\u9fff]+z|[\u002D\u058A\u05BE\u1400\u1806\u2010-\u2015\u2E17\u2E1A\u2E3A\u2E3B\u2E40\u301C\u3030\u30A0\uFE31\uFE32\uFE58\uFE63\uFF0D]+-u   [`´«»¨]"z['']'z&quot;?z&ampz"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} z\d:\d\d\s+$z\\nz
#\d{1,3}\bz	#\d{5,}\bz
\b\d{6,}\bz0[\S]+\.(?:png|jpg|jpeg|bmp|webp|eps|pdf|apk|mp4)z
[\"\']{2,}z[\.]{2,}z\s+\.\s+z	(?:\-|\_)   z\b[a-zA-Z]{1,3}\d{3,15}\bz\b[a-zA-Z]+\d+[a-zA-Z]+\bz\b\d+[a-zA-Z]+\d+\bz!(worldwide\s+)?(free\s+)?shippingz(free\s)?download(\sfree)?z\bclick\b\s(?:for|on)\s\w+z9\b(?:png|jpg|jpeg|bmp|webp|eps|pdf|apk|mp4)(\simage[s]?)?z\bpage\s+\d+\bz*\b\d*[a-zA-Z]+\d+[a-zA-Z]+\d+[a-zA-Z\d]*\bu   \b\d+\.?\d*[xх×]\d+\.?\d*\bz
\b\s+\:\s+z: z(\D[,\./])\bz\1 z\s+z^[\"\']([\w\W]+)[\"\']$z\1z^[\'\_,\-\:;]z[\'\_,\-\:\-\+]$z^\.\S+$)strulunquote_plusstriplowerr,   subr.   r-   lenfindallftfyfix_texthtmlunescape)r0   r4   regex2s      r1   
clean_textzTextPreprocessor.clean_text   s     4yt$zz|!!#vvj(D1 vv~
 vvmR. vv)2t4vv)2t4vv)2t4vv)2t4vv)2t4vv)2t4vv)2t4 vv L
 vv'd3vvgsD) vvj"d+vvgr4( vv;S$G vvnb$/ vvfc4( vvmR.vvlB-vvmR. vvI2tT vvmT40vvk4.vvd**D$7vvk4. L)rzz&$'(1,66&#t,D }}T"}}T]]401zz| vv2B=vv2B=vv,b$7 vv:BEvv3R>vv3R>vvRTVX\]vv'T2vvCT4Pvv6DA vvmUD1vvovt4vvfc4(

vv0%>vv&T2vv)35vvj"d+zz|r3   N)__name__
__module____qualname____doc__r2   r>   rK    r3   r1   r*   r*   l   s     5
$gs gs gr3   r*   a  
    Examples:
        ```py
        >>> import torch
        >>> from diffusers import PRXPipeline

        >>> # Load pipeline with from_pretrained
        >>> pipe = PRXPipeline.from_pretrained("Photoroom/prx-512-t2i-sft")
        >>> pipe.to("cuda")

        >>> prompt = "A digital painting of a rusty, vintage tram on a sandy beach"
        >>> image = pipe(prompt, num_inference_steps=28, guidance_scale=5.0).images[0]
        >>> image.save("prx_output.png")
        ```
c            +           e Zd ZdZdZddgZdgZdefdede	d	e
d
eeeef   deeeef      dee   f fdZed        Zed        Zed        Zd Z	 	 d4dededededej4                  dej6                  deej8                     deej:                     fdZ	 	 	 	 	 	 	 	 d5deee e   f   deej6                     de!dededeejD                     d eejD                     d!eejF                     d"eejF                     fd#Z$d$e e   dej6                  fd%Z%	 	 d6de e   dej6                  de!defd&Z&	 	 	 d7deee e   f   deded'e'd(ee e      deejD                     d eejD                     fd)Z( ejR                          e*e+      ddddd*dd+dddddddd,ddddgfdeee e   f   dedee   dee   d-ed.e e   d'e'dee   deeej8                  e ej8                     f      deej:                     deejD                     d eejD                     d!eejF                     d"eejF                     d/ee   d0e!d1e!d2ee,eee-gdf      d(e e   f&d3              Z. xZ/S )8PRXPipelinea+  
    Pipeline for text-to-image generation using PRX Transformer.

    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:
        transformer ([`PRXTransformer2DModel`]):
            The PRX transformer model to denoise the encoded image latents.
        scheduler ([`FlowMatchEulerDiscreteScheduler`]):
            A scheduler to be used in combination with `transformer` to denoise the encoded image latents.
        text_encoder ([`T5GemmaEncoder`]):
            Text encoder model for encoding prompts.
        tokenizer ([`T5TokenizerFast` or `GemmaTokenizerFast`]):
            Tokenizer for the text encoder.
        vae ([`AutoencoderKL`] or [`AutoencoderDC`]):
            Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
            Supports both AutoencoderKL (8x compression) and AutoencoderDC (32x compression).
    ztext_encoder->transformer->vaelatentsprompt_embedsvaeNtransformer	schedulertext_encoder	tokenizerdefault_sample_sizec                 ,   t         |           t        t        d      t	               | _        || _        d| _        | j                  |||||       | j                  | j                         |t        | j                        | _        y d | _        y )NzgPRXTransformer2DModel is not available. Please ensure the transformer_prx module is properly installed.      ?)rV   rW   rX   rY   rU   )rZ   )vae_scale_factor)superr2   r   ImportErrorr*   text_preprocessorrZ   _guidance_scaleregister_modulesregister_to_configr   r]   image_processor)r0   rV   rW   rX   rY   rU   rZ   	__class__s          r1   r2   zPRXPipeline.__init__  s     	 (y  "2!3#6 "#% 	 	
 	D4L4LM?#7I^I^#_D #'D r3   c                     | j                   yt        | j                   d      r| j                   j                  S dt        | j                   j                  j
                        dz
  z  S )N   spatial_compression_ratio      )rU   hasattrrh   rD   configblock_out_channelsr/   s    r1   r]   zPRXPipeline.vae_scale_factor=  sQ    884888988555TXX__??@1DEEr3   c                      | j                   dkD  S )zECheck if classifier-free guidance is enabled based on guidance scale.r\   ra   r/   s    r1   do_classifier_free_guidancez'PRXPipeline.do_classifier_free_guidanceF  s     ##c))r3   c                     | j                   S Nro   r/   s    r1   guidance_scalezPRXPipeline.guidance_scaleK  s    ###r3   c                 D    t        | j                  dd      }||S t        S )zDetermine the default resolution based on the loaded VAE and config.

        Returns:
            int: The default sample size (height/width) to use for generation.
        rZ   N)getattrrl   DEFAULT_RESOLUTION)r0   default_from_configs     r1   get_default_resolutionz"PRXPipeline.get_default_resolutionO  s*     &dkk3H$O*&&!!r3   
batch_sizenum_channels_latentsheightwidthdtypedevice	generatorc	                     |-| j                   }	||	z  ||	z  }}
|||
|f}t        ||||      }|S |j                  |      }|S )z2Prepare initial latents for the diffusion process.)r   r~   r}   )r]   r   to)r0   ry   rz   r{   r|   r}   r~   r   rS   spatial_compressionlatent_heightlatent_widthshapes                r1   prepare_latentszPRXPipeline.prepare_latents[  sl     ?"&"7"7--,, (M  !5}lSE"5IfTYZG  jj(Gr3   Tr8   rj   promptrp   negative_promptnum_images_per_promptnegative_prompt_embedsprompt_attention_masknegative_prompt_attention_maskc
                 &   || j                   }|,t        |t              r|g}| j                  ||||      \  }}}}	|dkD  r|j                  \  }
}}|j                  d|d      }|j                  |
|z  |d      }|$|j                  |
d      }|j                  |d      }|ra|_|j                  \  }
}}|j                  d|d      }|j                  |
|z  |d      }|	$|	j                  |
d      }	|	j                  |d      }	|||r|nd|r|	fS dfS )z\Encode text prompt using standard text encoder and tokenizer, or use precomputed embeddings.Nrj   )_execution_device
isinstancer>   _encode_prompt_standardr   repeatview)r0   r   r~   rp   r   r   rT   r   r   r   bs_embedseq_len_s                r1   encode_promptzPRXPipeline.encode_prompts  s    >++F &#&  ,,VV=XZij iM02HJh
 !1$#0#6#6 Hgq)004I1MM)..x:O/OQXZ\]M$0(=(B(B8R(P%(=(D(DEZ\](^% +/E/Q'='C'C$'1)?)F)FqJ_ab)c&)?)D)DXPeEegnpr)s&1=5S5X5XYace5f25S5Z5Z[prs5t2 !&A"t.I*	
 	
 PT	
 	
r3   promptsc                    |D cg c]  }| j                   j                  |       }}| j                  |d| j                  j                  ddd      }|d   j	                  |      |d   j                         j	                  |      fS c c}w )zTokenize and clean prompts.
max_lengthTpt)paddingr   
truncationreturn_attention_maskreturn_tensors	input_idsattention_mask)r`   rK   rY   model_max_lengthr   bool)r0   r   r~   r4   cleanedtokenss         r1   _tokenize_promptszPRXPipeline._tokenize_prompts  s    GNOt4))44T:OO ~~66"&   
 k"%%f-v6F/G/L/L/N/Q/QRX/YYY Ps   "B
c                 |   t        |      }|rt        |t              r|g|z  }||z   }n|}| j                  ||      \  }}t	        j
                         5  | j                  ||d      d   }	ddd       |r-	j                  |d      \  }
}|j                  |d      \  }}n	}|}d}
d}|||
|fS # 1 sw Y   FxY w)zNEncode prompt using standard text encoder and tokenizer with batch processing.T)r   r   output_hidden_stateslast_hidden_stateNr   dim)rD   r   r>   r   torchno_gradrX   split)r0   r   r~   rp   r   ry   prompts_to_encoder   r   
embeddingsuncond_text_embeddingstext_embeddingsuncond_cross_attn_maskcross_attn_masks                 r1   r   z#PRXPipeline._encode_prompt_standard  s     [
&/3/#2"3j"@ /& 8 &$($:$:;Lf$U!	>]]_ 	#**#-%) +  "	#J	# '6@6F6FzWX6F6Y3"O6D6J6J:[\6J6]3"O(O,O%)"%)"1GI___!	# 	#s   B22B;rs   "callback_on_step_end_tensor_inputsc           
      Z    ||t        d| d| d      ||t        d      |7t        |t              s't        |t              st        dt	        |             ||dkD  r|t        d       j
                  }||z  d	k7  s||z  d	k7  rt        d
| d| d| d      |dk  rt        d|       |t        |t              st        d|       |Mt         fd|D              s8t        d j                   d|D 	cg c]  }	|	 j                  vs|	 c}	       yyc c}	w )z,Check that all inputs are in correct format.NzCannot forward both `prompt`: z and `prompt_embeds`: z2. Please make sure to only forward one of the two.zeProvide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined.z2`prompt` has to be of type `str` or `list` but is r\   zWhen `prompt_embeds` is provided and `guidance_scale > 1.0`, `negative_prompt_embeds` must also be provided for classifier-free guidance.r   z-`height` and `width` have to be divisible by z	 but are z and .z'guidance_scale has to be >= 1.0 but is z=`callback_on_step_end_tensor_inputs` has to be a list but is c              3   :   K   | ]  }|j                   v   y wrr   )_callback_tensor_inputs).0kr0   s     r1   	<genexpr>z+PRXPipeline.check_inputs.<locals>.<genexpr>  s#      F
23A---F
s   z2`callback_on_step_end_tensor_inputs` has to be in z, but found )
ValueErrorr   r>   listtyper]   allr   )
r0   r   r{   r|   rs   r   rT   r   r   r   s
   `         r1   check_inputszPRXPipeline.check_inputs  s    -";08N}o ^0 0 
 >m3w  z&#'>zRXZ^G_QRVW]R^Q_`aa$#)=BXB`_ 
 #33''1,8K0Kq0P?@S?TT]^d]eejkpjqqrs  CF~FVWXX-9*MoquBvOPrOst  .9# F
7YF
 C
 DTEaEaDbbn  |^  pHvw  bc  ko  kG  kG  bGpq  pH  oI  J C
9 pHs   D(D(   g      @pilnum_inference_steps	timestepsoutput_typereturn_dictuse_resolution_binningcallback_on_step_endc                 
   | j                         }|xs |}|xs |}|r| j                  t        d      | j                  t        vr7t        dt        t        j                                d| j                   d      t        | j                     }||}}| j                  j                  |||      \  }}| j                  |||||||       | j                  |dvrt        d| d	      |t        |t              rd
}n-|t        |t
              rt        |      }n|j                  d   }| j                  }|| _        | j!                  ||| j"                  ||||||	      \  }}}}|}|}|?| j$                  j'                  ||       | j$                  j(                  }t        |      }n3| j$                  j'                  ||       | j$                  j(                  }t        |      | _        | j                  !| j                  j,                  j.                  }n | j0                  j,                  j2                  }| j5                  ||z  ||||j6                  ||	|
      }
i }dt9        t;        j<                  | j$                  j>                        j@                  j                               v } | rd|d<   | j"                  r9tC        jD                  ||gd      }!d}"| |tC        jD                  ||gd      }"n|}!|}"tG        t        |      || j$                  jH                  z  z
  d      }#| jK                  |      5 }$tM        |      D ]  \  }%}&| j"                  rxtC        jD                  |
|
gd      }'|&jO                         | j$                  j,                  jP                  z  jS                  d
      jU                  d      jW                  |      }(nQ|
}'|&jO                         | j$                  j,                  jP                  z  jS                  d
      jW                  |      }(| j1                  |'|(|!|"d      d   })| j"                  r!|)jY                  dd      \  }*}+|*||+|*z
  z  z   }) | j$                  j>                  |)|&|
fi |jZ                  }
|$i },|D ]  }-t]               |-   |,|-<     || |%|&|,       |%t        |      d
z
  k(  s+|%d
z   |#kD  s|%d
z   | j$                  jH                  z  dk(  s|$j_                           	 ddd       |dk(  s|dk(  r| j                  |
}.nta        | j                  j,                  dd      }/ta        | j                  j,                  dd      }0|
|/z  |0z   }
| j                  jc                  |
d      d   }.|r| j                  je                  |.      }.| j                  jg                  |.|      }.| ji                          |s|.fS tk        |.      S # 1 sw Y   xY w)a  
        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`, *optional*, defaults to `""`):
                The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored
                if `guidance_scale` is less than `1`).
            height (`int`, *optional*, defaults to self.transformer.config.sample_size * self.vae_scale_factor):
                The height in pixels of the generated image.
            width (`int`, *optional*, defaults to self.transformer.config.sample_size * self.vae_scale_factor):
                The width in pixels of the generated image.
            num_inference_steps (`int`, *optional*, defaults to 28):
                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 with schedulers which support a `timesteps` argument
                in their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
                passed will be used. Must be in descending order.
            guidance_scale (`float`, *optional*, defaults to 4.0):
                Guidance scale as defined in [Classifier-Free Diffusion
                Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` is defined as `w` of equation 2.
                of [Imagen Paper](https://huggingface.co/papers/2205.11487). 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.
            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.Tensor`, *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 be 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.
            negative_prompt_embeds (`torch.FloatTensor`, *optional*):
                Pre-generated negative text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt
                weighting. If not provided and `guidance_scale > 1`, negative embeddings will be generated from an
                empty string.
            prompt_attention_mask (`torch.BoolTensor`, *optional*):
                Pre-generated attention mask for `prompt_embeds`. If not provided, attention mask will be generated
                from `prompt` input argument.
            negative_prompt_attention_mask (`torch.BoolTensor`, *optional*):
                Pre-generated attention mask for `negative_prompt_embeds`. If not provided and `guidance_scale > 1`,
                attention mask will be generated from an empty string.
            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.prx.PRXPipelineOutput`] instead of a plain tuple.
            use_resolution_binning (`bool`, *optional*, defaults to `True`):
                If set to `True`, the requested height and width are first mapped to the closest resolutions using
                predefined aspect ratio bins. After the produced latents are decoded into images, they are resized back
                to the requested resolution. Useful for generating non-square images at optimal resolutions.
            callback_on_step_end (`Callable`, *optional*):
                A function that calls at the end of each denoising steps during the inference. The function is called
                with the following arguments: `callback_on_step_end(self, step, timestep, callback_kwargs)`.
                `callback_kwargs` will include a list of all tensors as specified by
                `callback_on_step_end_tensor_inputs`.
            callback_on_step_end_tensor_inputs (`List`, *optional*):
                The list of tensor inputs for the `callback_on_step_end` function. The tensors specified in the list
                will be passed as `callback_kwargs` argument. You will only be able to include tensors that are listed
                in the `._callback_tensor_inputs` attribute.

        Examples:

        Returns:
            [`~pipelines.prx.PRXPipelineOutput`] or `tuple`: [`~pipelines.prx.PRXPipelineOutput`] if `return_dict` is
            True, otherwise a `tuple. When returning a tuple, the first element is a list with the generated images.
        NzResolution binning requires a VAE with image_processor, but VAE is not available. Set use_resolution_binning=False or provide a VAE.z@Resolution binning is only supported for default_sample_size in z
, but got zC. Set use_resolution_binning=False to disable aspect ratio binning.)ratios)latentr   z!VAE is required for output_type='zj' but it is not available. Either provide a VAE or set output_type='latent' or 'pt' to get latent outputs.rj   r   )rp   r   r   rT   r   r   r   )r   r~   )r~   etag        r   )totalri   F)hidden_statestimestepencoder_hidden_statesr   r   r   r   scaling_factorg{P?shift_factor)r   )r   )images)6rx   rd   r   rZ   ASPECT_RATIO_BINSr   keysclassify_height_width_binr   rU   r   r>   rD   r   r   ra   r   rp   rW   set_timestepsr   num_timestepsrl   latent_channelsrV   in_channelsr   r}   setinspect	signaturestep
parametersr   catmaxorderprogress_bar	enumeratefloatnum_train_timestepsr   r   r   chunkprev_samplelocalsupdateru   decoderesize_and_crop_tensorpostprocessmaybe_free_model_hooksr   )1r0   r   r   r{   r|   r   r   rs   r   r   rS   rT   r   r   r   r   r   r   r   r   default_resolutionaspect_ratio_binorig_height
orig_widthry   r~   r   r   r   r   rz   extra_step_kwargsaccepts_etaca_embedca_masknum_warmup_stepsr   it
latents_int_cont
noise_prednoise_uncond
noise_textcallback_kwargsr   imager   r   s1                                                    r1   __call__zPRXPipeline.__call__  sK   H "88:--++!##+ I  ''/@@ VW[\m\r\r\tWuVv w#7788{}   11I1IJ '-eK 00JJ6SXaqJrMFE 	."	
 883C C3K= Ab b 
 *VS"9JJvt$<VJ&,,Q/J ''- \`[m[m(,(H(H+"7'#9"7+I \n 
\
X*@BX (!7  NN((9V(L00I"%i.NN(()<V(L00I ^ 88#'88??#B#B  $(#3#3#:#:#F#F &&.. !!	
 s7#4#4T^^5H5H#I#T#T#Y#Y#[\\'*e$ ++yy"8/!JPQRHG*/E/Q))%;_$MSTU&H%G s9~0CdnnFZFZ0ZZ\]^%89 %	*\!), $*133!&GW+=1!EJggi$..*?*?*S*SSYYZ[\ccdefiijpqF!(Jggi$..*?*?*S*SSYYZ[\__`fgF "--",#*2#* % .  
 33/9/?/?q/?/I,L*!-*|B[0\!\J .$..--j!WZHYZff'3&(O? 9-3Xa[*9(q!_E I**A9I/IqSTuX\XfXfXlXlNlpqNq '')I$*%	*P ("{d':txx?OE %TXX__6FPN"488??NCHL/<?GHHOOGO?BE%,,CCE:Wbc ((44U4TE 	##%8O ..}%	* %	*s   FW9W9=W99X)NN)NTr8   rj   NNNN)Tr8   )NNN)0rL   rM   rN   rO   model_cpu_offload_seqr   _optional_componentsrv   r   r   r   r   r
   r	   r   r   r   r   intr2   propertyr]   rp   rs   rx   r   r}   r~   	GeneratorTensorr   r>   r   r   FloatTensor
BoolTensorr   r   r   r   r   r   r   EXAMPLE_DOC_STRINGr   r   r  __classcell__)re   s   @r1   rR   rR      s   ( =(/:!7 >B-?!(*!( 3!( %	!(
 *<mKL!( eM=89:!( &c]!(F F F * * $ $
"( 04*. " 	
  {{  EOO, %,,'6 *.,0!%&59>B<@EI2
c49n%2
 &2
 &*	2

 2
  #2
   1 122
 !)):): ;2
  ((8(892
 )11A1A(B2
hZc ZELL Z" -1!$`S	$` $` &*	$`
 $`X CG59>B2c49n%2 2 	2
 2 -5T#Y,?2   1 122 !)):): ;2h U]]_12 )-! $##%# #/0MQ*.59>B<@EI%* '+KO9B)R/c49n%R/ R/ 	R/
 }R/ !R/ 9R/ R/  (}R/ E%//43H"HIJR/ %,,'R/   1 12R/ !)):): ;R/  ((8(89R/ )11A1A(BR/  c]!R/" #R/$ !%%R/& 'xc40@$0F'GH'R/( -1I)R/ 3 R/r3   rR   )5rH   r   r,   urllib.parseparser?   typingr   r   r   r   r   rF   r   transformersr   r	   r
   ,transformers.models.t5gemma.modeling_t5gemmar   diffusers.image_processorr   diffusers.loadersr   r   r   diffusers.modelsr   r   -diffusers.models.transformers.transformer_prxr   "diffusers.pipelines.pipeline_utilsr   'diffusers.pipelines.prx.pipeline_outputr   diffusers.schedulersr   diffusers.utilsr   r   diffusers.utils.torch_utilsr   rv   ASPECT_RATIO_256_BINASPECT_RATIO_512_BINASPECT_RATIO_1024_BINr   
get_loggerrL   loggerr*   r  rR   rP   r3   r1   <module>r      s     	  8 8   
 H : _ _ 9 O @ E @ 5   #J:#J:#J#J:  :#J:#J#J#J:#J#J#J#J#J:  
S$K
S$K S$K S$K	
 S$K S$K S$K S$K S$K S$K S$K 
D$< T3K T3K T3K  T3K!" T3K#$ 3K#;3K3K3K3K3K1 8 
	
  
		H	%| |~ "f/	f/r3   