ó
    oM‡j�S  ã            
       óà   • S SK r S SKrS SK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JrJr  SSKJr  SSKJr  SSKJrJrJrJ r J!r!   " S S\\\\\
\5      r"g)é    Né   )ÚConfigMixinÚregister_to_config)ÚPeftAdapterMixin)ÚFromOriginalModelMixin)Ú	deprecate)Úapply_forward_hooké   )ÚAttentionMixin)ÚADDED_KV_ATTENTION_PROCESSORSÚCROSS_ATTENTION_PROCESSORSÚ	AttentionÚAttnAddedKVProcessorÚAttnProcessorÚFusedAttnProcessor2_0)ÚAutoencoderKLOutput)Ú
ModelMixiné   )ÚAutoencoderMixinÚDecoderÚDecoderOutputÚDiagonalGaussianDistributionÚEncoderc            (       óè  ^ • \ rS rSrSrSrSS/r\                  S3S\S\S	\	\
S
4   S\	\
S
4   S\	\S
4   S\	\S
4   S-  S\S\
S\S\S\S\S\S\S\S\S\S\	\\4   4$U 4S jjj5       rS rS\R                   S\R                   4S jr\ S4S\R                   S\S\\	\   -  4S  jj5       rS4S!\R                   S\S\\R                   -  4S" jjr\ S5S!\R0                  S\S\\R0                  -  4S# jj5       rS$\R                   S%\R                   S&\S\R                   4S' jrS$\R                   S%\R                   S&\S\R                   4S( jrS\R                   S\R                   4S) jrS4S\R                   S\S\4S* jjrS4S!\R                   S\S\\R                   -  4S+ jjr   S6S,\R                   S-\S\S.\R>                  S-  S\\R                   -  4
S/ jjr S0 r!S1 r"S2r#U =r$$ )7ÚAutoencoderKLFlux2é&   a“  
A VAE model with KL loss for encoding images into latents and decoding latent representations into images.

This model inherits from [`ModelMixin`]. Check the superclass documentation for it's generic methods implemented
for all models (such as downloading or saving).

Parameters:
    in_channels (int, *optional*, defaults to 3): Number of channels in the input image.
    out_channels (int,  *optional*, defaults to 3): Number of channels in the output.
    down_block_types (`tuple[str]`, *optional*, defaults to `("DownEncoderBlock2D",)`):
        Tuple of downsample block types.
    up_block_types (`tuple[str]`, *optional*, defaults to `("UpDecoderBlock2D",)`):
        Tuple of upsample block types.
    block_out_channels (`tuple[int]`, *optional*, defaults to `(64,)`):
        Tuple of block output channels.
    act_fn (`str`, *optional*, defaults to `"silu"`): The activation function to use.
    latent_channels (`int`, *optional*, defaults to 4): Number of channels in the latent space.
    sample_size (`int`, *optional*, defaults to `32`): Sample input size.
    force_upcast (`bool`, *optional*, default to `True`):
        If enabled it will force the VAE to run in float32 for high image resolution pipelines, such as SD-XL. VAE
        can be fine-tuned / trained to a lower range without losing too much precision in which case `force_upcast`
        can be set to `False` - see: https://huggingface.co/madebyollin/sdxl-vae-fp16-fix
    mid_block_add_attention (`bool`, *optional*, default to `True`):
        If enabled, the mid_block of the Encoder and Decoder will have attention blocks. If set to false, the
        mid_block will only have resnet blocks
TÚBasicTransformerBlockÚResnetBlock2DNÚin_channelsÚout_channelsÚdown_block_types.Úup_block_typesÚblock_out_channelsÚdecoder_block_out_channelsÚlayers_per_blockÚact_fnÚlatent_channelsÚnorm_num_groupsÚsample_sizeÚforce_upcastÚuse_quant_convÚuse_post_quant_convÚmid_block_add_attentionÚbatch_norm_epsÚbatch_norm_momentumÚ
patch_sizec                 ó  >• [         TU ]  5         [        UU	UUUUU
SUS9	U l        [	        U	UUU=(       d    UUU
UUS9U l        U(       a  [        R                  " SU	-  SU	-  S5      OS U l        U(       a  [        R                  " X™S5      OS U l	        [        R                  " [        R                  " U5      U	-  UUSSS9U l        SU l        SU l        U R                   R"                  U l        ['        U R                   R"                  [(        [*        45      (       a  U R                   R"                  S   OU R                   R"                  n[-        US[/        U R                   R0                  5      S-
  -  -  5      U l        S	U l        g )
NT)	r   r    r!   r#   r%   r&   r(   Údouble_zr-   )r   r    r"   r#   r%   r(   r&   r-   r
   r   F)ÚepsÚmomentumÚaffineÚtrack_running_statsr   g      Ð?)ÚsuperÚ__init__r   Úencoderr   ÚdecoderÚnnÚConv2dÚ
quant_convÚpost_quant_convÚBatchNorm2dÚmathÚprodÚbnÚuse_slicingÚ
use_tilingÚconfigr)   Útile_sample_min_sizeÚ
isinstanceÚlistÚtupleÚintÚlenr#   Útile_latent_min_sizeÚtile_overlap_factor)Úselfr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   Ú	__class__s                      €ÚÀC:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\diffusers/models/autoencoders/autoencoder_kl_flux2.pyr8   ÚAutoencoderKLFlux2.__init__G   sp  ø€ ôJ 	‰ÑÔô Ø#Ø(Ø-Ø1Ø-ØØ+ØØ$;ñ

ˆŒô Ø'Ø%Ø)Ø9×OÐ=OØ-Ø+ØØ$;ñ	
ˆŒö Ucœ"Ÿ)š) A¨Ñ$7¸¸_Ñ9LÈaÔPÐhlˆŒÞQdœrŸyšy¨È1ÔMÐjnˆÔä—.’.Ü�IŠI�jÓ! OÑ3ØØ(ØØ $ñ
ˆŒð !ˆÔØˆŒð %)§K¡K×$;Ñ$;ˆÔ!ô ˜$Ÿ+™+×1Ñ1´D¼%°=×AÑAð �K‰K×#Ñ# AÒ&à—‘×(Ñ(ð 	ô
 %(¨°q¼SÀÇÁ×A_ÑA_Ó=`ÐcdÑ=dÑ7eÑ(fÓ$gˆÔ!Ø#'ˆÕ ó    c           	      ó~  • [        S U R                  R                  5        5       5      (       a  [        5       nOr[        S U R                  R                  5        5       5      (       a  [	        5       nO8[        S[        [        U R                  R                  5       5      5       35      eU R                  U5        g)zU
Disables custom attention processors and sets the default attention implementation.
c              3   óF   #   • U  H  oR                   [        ;   v •  M     g 7f©N)rO   r   ©Ú.0Úprocs     rP   Ú	<genexpr>Ú@AutoencoderKLFlux2.set_default_attn_processor.<locals>.<genexpr>¤   s   é € ÐiÒKhÀ4�~‰~Ô!>Ö>ÒKhùó   ‚!c              3   óF   #   • U  H  oR                   [        ;   v •  M     g 7frU   )rO   r   rV   s     rP   rY   rZ   ¦   s   é € ÐhÒJgÀ$—‘Ô#=Ö=ÒJgùr[   zOCannot call `set_default_attn_processor` when attention processors are of type N)	ÚallÚattn_processorsÚvaluesr   r   Ú
ValueErrorÚnextÚiterÚset_attn_processor)rN   Ú	processors     rP   Úset_default_attn_processorÚ-AutoencoderKLFlux2.set_default_attn_processor    sº   € ô ÑiÈ4×K_ÑK_×KfÑKfÔKhÓi×iÑiÜ,Ó.‰IÜÑhÈ$×J^ÑJ^×JeÑJeÔJgÓh×hÑhÜ%›‰IäØaÔbfÔgkÐlp÷  mAñ  mA÷  mHñ  mHó  mJó  hKó  cLð  bMð  Nóð ð 	×Ñ 	Õ*rR   ÚxÚreturnc                 ó  • UR                   u  p#pEU R                  (       a/  XPR                  :”  d  X@R                  :”  a  U R                  U5      $ U R	                  U5      nU R
                  b  U R                  U5      nU$ rU   )ÚshaperD   rF   Ú_tiled_encoder9   r=   )rN   rg   Ú
batch_sizeÚnum_channelsÚheightÚwidthÚencs          rP   Ú_encodeÚAutoencoderKLFlux2._encode¯   sh   € Ø23·'±'Ñ/ˆ
 &à�?�? ×(AÑ(AÓ AÀV×NgÑNgÓEgØ×%Ñ% aÓ(Ð(à�l‰l˜1‹oˆØ�?‰?Ñ&Ø—/‘/ #Ó&ˆCàˆ
rR   Úreturn_dictc                 ó>  • U R                   (       aY  UR                  S   S:”  aF  UR                  S5       Vs/ s H  o0R                  U5      PM     nn[        R
                  " U5      nOU R                  U5      n[        U5      nU(       d  U4$ [        US9$ s  snf )aÈ  
Encode a batch of images into latents.

Args:
    x (`torch.Tensor`): Input batch of images.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether to return a [`~models.autoencoder_kl.AutoencoderKLOutput`] instead of a plain tuple.

Returns:
        The latent representations of the encoded images. If `return_dict` is True, a
        [`~models.autoencoder_kl.AutoencoderKLOutput`] is returned, otherwise a plain `tuple` is returned.
r   r   ©Úlatent_dist)rC   rj   Úsplitrq   ÚtorchÚcatr   r   )rN   rg   rs   Úx_sliceÚencoded_slicesÚhÚ	posteriors          rP   ÚencodeÚAutoencoderKLFlux2.encode»   s   € ð  ×× §¡¨¡
¨Q£ØCDÇ7Á7È1Ä:ÓNÂ:¸Ÿl™l¨7Ö3Á:ˆNÐNÜ—	’	˜.Ó)‰Aà—‘˜Q“ˆAä0°Ó3ˆ	æØ�<Ðä"¨yÑ9Ð9ùò Os   ¸BÚzc                 ó:  • U R                   (       aI  UR                  S   U R                  :”  d  UR                  S   U R                  :”  a  U R                  XS9$ U R                  b  U R	                  U5      nU R                  U5      nU(       d  U4$ [        US9$ )Néÿÿÿÿéþÿÿÿ)rs   ©Úsample)rD   rj   rL   Útiled_decoder>   r:   r   )rN   r€   rs   Údecs       rP   Ú_decodeÚAutoencoderKLFlux2._decodeØ   s‡   € Ø�?�? §¡¨¡¨d×.GÑ.GÓ GÈ1Ï7É7ÐSUÉ;ÐY]×YrÑYrÓKrØ×$Ñ$ QÐ$Ð@Ð@à×ÑÑ+Ø×$Ñ$ QÓ'ˆAà�l‰l˜1‹oˆæØ�6ˆMä CÑ(Ð(rR   c                 óP  • U R                   (       ac  UR                  S   S:”  aP  UR                  S5       Vs/ s H  o@R                  U5      R                  PM     nn[
        R                  " U5      nOU R                  U5      R                  nU(       d  U4$ [        US9$ s  snf )aœ  
Decode a batch of images.

Args:
    z (`torch.Tensor`): Input batch of latent vectors.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether to return a [`~models.vae.DecoderOutput`] instead of a plain tuple.

Returns:
    [`~models.vae.DecoderOutput`] or `tuple`:
        If return_dict is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
        returned.

r   r   r„   )rC   rj   rw   rˆ   r…   rx   ry   r   )rN   r€   rs   Ú	generatorÚz_sliceÚdecoded_slicesÚdecodeds          rP   ÚdecodeÚAutoencoderKLFlux2.decodeæ   s‚   € ð$ ×× §¡¨¡
¨Q£ØJKÏ'É'ÐRSÌ*ÓUÊ*¸wŸl™l¨7Ó3×:Ô:É*ˆNÐUÜ—i’i Ó/‰Gà—l‘l 1“o×,Ñ,ˆGæØ�:Ðä GÑ,Ð,ùò Vs   ¸$B#ÚaÚbÚblend_extentc                 óò   • [        UR                  S   UR                  S   U5      n[        U5       H@  nUS S 2S S 2U* U-   S S 24   SXC-  -
  -  US S 2S S 2US S 24   XC-  -  -   US S 2S S 2US S 24'   MB     U$ )Nr
   r   ©Úminrj   Úrange)rN   r‘   r’   r“   Úys        rP   Úblend_vÚAutoencoderKLFlux2.blend_v  sˆ   € Ü˜1Ÿ7™7 1™: q§w¡w¨q¡z°<Ó@ˆÜ�|Ö$ˆAØša¢ \ M°AÑ$5²qÐ8Ñ9¸QÀÑAQÑ=QÑRÐUVÒWXÒZ[Ð]^Ò`aÐWaÑUbÐfgÑfvÑUwÑwˆAŠa’�A’qˆj‹Mñ %àˆrR   c                 óò   • [        UR                  S   UR                  S   U5      n[        U5       H@  nUS S 2S S 2S S 2U* U-   4   SXC-  -
  -  US S 2S S 2S S 2U4   XC-  -  -   US S 2S S 2S S 2U4'   MB     U$ )Nr   r   r•   )rN   r‘   r’   r“   rg   s        rP   Úblend_hÚAutoencoderKLFlux2.blend_h	  sˆ   € Ü˜1Ÿ7™7 1™: q§w¡w¨q¡z°<Ó@ˆÜ�|Ö$ˆAØša¢¢A¨ }°qÑ'8Ð8Ñ9¸QÀÑAQÑ=QÑRÐUVÒWXÒZ[Ò]^Ð`aÐWaÑUbÐfgÑfvÑUwÑwˆAŠa’’A�qˆj‹Mñ %àˆrR   c           
      óÒ  • [        U R                  SU R                  -
  -  5      n[        U R                  U R                  -  5      nU R                  U-
  n/ n[	        SUR
                  S   U5       H®  n/ n[	        SUR
                  S   U5       Hz  nUSS2SS2XfU R                  -   2XˆU R                  -   24   n	U R                  U	5      n	U R                  R                  (       a  U R                  U	5      n	UR                  U	5        M|     UR                  U5        M°     / n
[        U5       Hœ  u  pg/ n[        U5       Hb  u  p‰US:”  a  U R                  XVS-
     U   X“5      n	US:”  a  U R                  XxS-
     X“5      n	UR                  U	SS2SS2SU2SU24   5        Md     U
R                  [        R                  " USS95        Mž     [        R                  " U
SS9nU$ )a£  Encode a batch of images using a tiled encoder.

When this option is enabled, the VAE will split the input tensor into tiles to compute encoding in several
steps. This is useful to keep memory use constant regardless of image size. The end result of tiled encoding is
different from non-tiled encoding because each tile uses a different encoder. To avoid tiling artifacts, the
tiles overlap and are blended together to form a smooth output. You may still see tile-sized changes in the
output, but they should be much less noticeable.

Args:
    x (`torch.Tensor`): Input batch of images.

Returns:
    `torch.Tensor`:
        The latent representation of the encoded videos.
r   r   r
   r   N©Údim)rJ   rF   rM   rL   r—   rj   r9   rE   r+   r=   ÚappendÚ	enumerater™   rœ   rx   ry   )rN   rg   Úoverlap_sizer“   Ú	row_limitÚrowsÚiÚrowÚjÚtileÚresult_rowsÚ
result_rowrp   s                rP   rk   Ú AutoencoderKLFlux2._tiled_encode  sÅ  € ô" ˜4×4Ñ4¸¸D×<TÑ<TÑ8TÑUÓVˆÜ˜4×4Ñ4°t×7OÑ7OÑOÓPˆØ×-Ñ-°Ñ<ˆ	ð ˆÜ�q˜!Ÿ'™' !™* lÖ3ˆAØˆCÜ˜1˜aŸg™g a™j¨,Ö7�ØššA˜q t×'@Ñ'@Ñ#@Ð@À!È$×JcÑJcÑFcÐBcÐcÑd�Ø—|‘| DÓ)�Ø—;‘;×-×-ØŸ?™?¨4Ó0�DØ—
‘
˜4Ö ñ 8ð �K‰K˜Öñ 4ð ˆÜ –o‰FˆAØˆJÜ$ Sž>‘�ð �q“5ØŸ<™<¨°©U©°A©¸ÓK�DØ�q“5ØŸ<™<¨°©E©
°DÓG�DØ×!Ñ! $¢qª!¨Z¨i¨Z¸¸)¸Ð'CÑ"DÖEñ *ð ×ÑœuŸyšy¨¸Ñ;Ö<ñ &ô �iŠi˜¨Ñ+ˆØˆ
rR   c           
      ó&  • Sn[        SSUSS9  [        U R                  SU R                  -
  -  5      n[        U R                  U R                  -  5      nU R                  U-
  n/ n[        SUR                  S   U5       H®  n/ n	[        SUR                  S	   U5       Hz  n
US
S
2S
S
2XˆU R                  -   2XªU R                  -   24   nU R                  U5      nU R                  R                  (       a  U R                  U5      nU	R                  U5        M|     UR                  U	5        M°     / n[        U5       Hœ  u  p‰/ n[        U	5       Hb  u  p«US:”  a  U R                  XxS-
     U
   Xµ5      nU
S:”  a  U R                  XšS-
     Xµ5      nUR                  US
S
2S
S
2S
U2S
U24   5        Md     UR                  [        R                   " US	S95        Mž     [        R                   " USS9n[#        U5      nU(       d  U4$ [%        US9$ )aÈ  Encode a batch of images using a tiled encoder.

When this option is enabled, the VAE will split the input tensor into tiles to compute encoding in several
steps. This is useful to keep memory use constant regardless of image size. The end result of tiled encoding is
different from non-tiled encoding because each tile uses a different encoder. To avoid tiling artifacts, the
tiles overlap and are blended together to form a smooth output. You may still see tile-sized changes in the
output, but they should be much less noticeable.

Args:
    x (`torch.Tensor`): Input batch of images.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether or not to return a [`~models.autoencoder_kl.AutoencoderKLOutput`] instead of a plain tuple.

Returns:
    [`~models.autoencoder_kl.AutoencoderKLOutput`] or `tuple`:
        If return_dict is True, a [`~models.autoencoder_kl.AutoencoderKLOutput`] is returned, otherwise a plain
        `tuple` is returned.
aC  The tiled_encode implementation supporting the `return_dict` parameter is deprecated. In the future, the implementation of this method will be replaced with that of `_tiled_encode` and you will no longer be able to pass `return_dict`. You will also have to create a `DiagonalGaussianDistribution()` from the returned value.Útiled_encodez1.0.0F)Ústandard_warnr   r   r
   r   NrŸ   ru   )r   rJ   rF   rM   rL   r—   rj   r9   rE   r+   r=   r¡   r¢   r™   rœ   rx   ry   r   r   )rN   rg   rs   Údeprecation_messager£   r“   r¤   r¥   r¦   r§   r¨   r©   rª   r«   Úmomentsr}   s                   rP   r®   ÚAutoencoderKLFlux2.tiled_encode?  sú  € ð(~ð 	ô
 	�. 'Ð+>ÈeÒTä˜4×4Ñ4¸¸D×<TÑ<TÑ8TÑUÓVˆÜ˜4×4Ñ4°t×7OÑ7OÑOÓPˆØ×-Ñ-°Ñ<ˆ	ð ˆÜ�q˜!Ÿ'™' !™* lÖ3ˆAØˆCÜ˜1˜aŸg™g a™j¨,Ö7�ØššA˜q t×'@Ñ'@Ñ#@Ð@À!È$×JcÑJcÑFcÐBcÐcÑd�Ø—|‘| DÓ)�Ø—;‘;×-×-ØŸ?™?¨4Ó0�DØ—
‘
˜4Ö ñ 8ð �K‰K˜Öñ 4ð ˆÜ –o‰FˆAØˆJÜ$ Sž>‘�ð �q“5ØŸ<™<¨°©U©°A©¸ÓK�DØ�q“5ØŸ<™<¨°©E©
°DÓG�DØ×!Ñ! $¢qª!¨Z¨i¨Z¸¸)¸Ð'CÑ"DÖEñ *ð ×ÑœuŸyšy¨¸Ñ;Ö<ñ &ô —)’)˜K¨QÑ/ˆÜ0°Ó9ˆ	æØ�<Ðä"¨yÑ9Ð9rR   c           
      óô  • [        U R                  SU R                  -
  -  5      n[        U R                  U R                  -  5      nU R                  U-
  n/ n[	        SUR
                  S   U5       H®  n/ n[	        SUR
                  S   U5       Hz  n	USS2SS2XwU R                  -   2X™U R                  -   24   n
U R                  R                  (       a  U R                  U
5      n
U R                  U
5      nUR                  U5        M|     UR                  U5        M°     / n[        U5       Hœ  u  px/ n[        U5       Hb  u  pšUS:”  a  U R                  XgS-
     U	   X¤5      n
U	S:”  a  U R                  X‰S-
     X¤5      n
UR                  U
SS2SS2SU2SU24   5        Md     UR                  [        R                  " USS95        Mž     [        R                  " USS9nU(       d  U4$ [!        US9$ )a¸  
Decode a batch of images using a tiled decoder.

Args:
    z (`torch.Tensor`): Input batch of latent vectors.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether or not to return a [`~models.vae.DecoderOutput`] instead of a plain tuple.

Returns:
    [`~models.vae.DecoderOutput`] or `tuple`:
        If return_dict is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
        returned.
r   r   r
   r   NrŸ   r„   )rJ   rL   rM   rF   r—   rj   rE   r,   r>   r:   r¡   r¢   r™   rœ   rx   ry   r   )rN   r€   rs   r£   r“   r¤   r¥   r¦   r§   r¨   r©   rŽ   rª   r«   r‡   s                  rP   r†   ÚAutoencoderKLFlux2.tiled_decode}  s×  € ô ˜4×4Ñ4¸¸D×<TÑ<TÑ8TÑUÓVˆÜ˜4×4Ñ4°t×7OÑ7OÑOÓPˆØ×-Ñ-°Ñ<ˆ	ð ˆÜ�q˜!Ÿ'™' !™* lÖ3ˆAØˆCÜ˜1˜aŸg™g a™j¨,Ö7�ØššA˜q t×'@Ñ'@Ñ#@Ð@À!È$×JcÑJcÑFcÐBcÐcÑd�Ø—;‘;×2×2Ø×/Ñ/°Ó5�DØŸ,™, tÓ,�Ø—
‘
˜7Ö#ñ 8ð �K‰K˜Öñ 4ð ˆÜ –o‰FˆAØˆJÜ$ Sž>‘�ð �q“5ØŸ<™<¨°©U©°A©¸ÓK�DØ�q“5ØŸ<™<¨°©E©
°DÓG�DØ×!Ñ! $¢qª!¨Z¨i¨Z¸¸)¸Ð'CÑ"DÖEñ *ð ×ÑœuŸyšy¨¸Ñ;Ö<ñ &ô �iŠi˜¨Ñ+ˆÞØ�6ˆMä CÑ(Ð(rR   r…   Úsample_posteriorr‹   c                 óæ   • UnU R                  U5      R                  nU(       a  UR                  US9nOUR                  5       nU R	                  U5      R                  nU(       d  U4$ [        US9$ )a”  
Args:
    sample (`torch.Tensor`): Input sample.
    sample_posterior (`bool`, *optional*, defaults to `False`):
        Whether to sample from the posterior.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
    generator (`torch.Generator`, *optional*):
        A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
        deterministic.

Returns:
    [`~models.vae.DecoderOutput`] or `tuple`:
        If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
        returned.
)r‹   r„   )r~   rv   r…   Úmoder�   r   )	rN   r…   rµ   rs   r‹   rg   r}   r€   r‡   s	            rP   ÚforwardÚAutoencoderKLFlux2.forward®  sf   € ð. ˆØ—K‘K “N×.Ñ.ˆ	ÞØ× Ñ ¨9Ð Ð5‰Aà—‘Ó ˆAØ�k‰k˜!‹n×#Ñ#ˆæØ�6ˆMä CÑ(Ð(rR   c                 ó‚  • SU l         U R                  R                  5        H3  u  pS[        UR                  R
                  5      ;   d  M*  [        S5      e   U R                  U l         U R                  5        H)  n[        U[        5      (       d  M  UR                  SS9  M+     U R                  [        5       5        g)uò   
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
are fused. For cross-attention modules, key and value projection matrices are fused.

> [!WARNING] > This API is ðŸ§ª experimental.
NÚAddedzQ`fuse_qkv_projections()` is not supported for models having added KV projections.T)Úfuse)Úoriginal_attn_processorsr^   ÚitemsÚstrrO   Ú__name__r`   ÚmodulesrG   r   Úfuse_projectionsrc   r   )rN   Ú_Úattn_processorÚmodules       rP   Úfuse_qkv_projectionsÚ'AutoencoderKLFlux2.fuse_qkv_projectionsÓ  sŸ   € ð )-ˆÔ%à!%×!5Ñ!5×!;Ñ!;Ö!=ÑˆAØœ#˜n×6Ñ6×?Ñ?Ó@Õ@Ü Ð!tÓuÐuñ ">ð )-×(<Ñ(<ˆÔ%à—l‘l–nˆFÜ˜&¤)×,Ó,Ø×'Ñ'¨TÐ'Ó2ñ %ð 	×ÑÔ 5Ó 7Õ8rR   c                 óV   • U R                   b  U R                  U R                   5        gg)u^   Disables the fused QKV projection if enabled.

> [!WARNING] > This API is ðŸ§ª experimental.

N)r½   rc   )rN   s    rP   Úunfuse_qkv_projectionsÚ)AutoencoderKLFlux2.unfuse_qkv_projectionsé  s)   € ð ×(Ñ(Ñ4Ø×#Ñ# D×$AÑ$AÕBð 5rR   )rB   r:   r9   r½   r>   r=   rL   rM   rF   rC   rD   )r   r   )ÚDownEncoderBlock2DrË   rË   rË   )ÚUpDecoderBlock2DrÌ   rÌ   rÌ   )é€   é   é   rÏ   Nr
   Úsilué    rÑ   i   TTTTg-Cëâ6?gš™™™™™¹?)r
   r
   )T)TN)FTN)%rÀ   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú _supports_gradient_checkpointingÚ_no_split_modulesr   rJ   rI   r¿   ÚboolÚfloatr8   re   rx   ÚTensorrq   r	   r   r   r~   r   rˆ   ÚFloatTensorr�   r™   rœ   rk   r®   r†   Ú	Generatorr¸   rÆ   rÉ   Ú__static_attributes__Ú__classcell__)rO   s   @rP   r   r   &   sZ  ø† ñð6 (,Ð$Ø0°/ÐBÐàð Øð-
ð+
ð/
ð >BØ !ØØ!Ø!ØØ!Ø#Ø$(Ø(,Ø $Ø%(Ø&,ñEU(àðU(ð ðU(ð    S ™/ð	U(ð ˜c 3˜h™ðU(ð  " # s (™Oð!U(ð, %*¨#¨s¨(¡O°dÑ$:ð-U(ð. ð/U(ð0 ð1U(ð2 ð3U(ð4 ð5U(ð6 ð7U(ð8 ð9U(ð: ð;U(ð< "ð=U(ð> "&ð?U(ð@ ðAU(ðB #ðCU(ðD ˜#˜s˜(‘O÷EU(ó ðU(òp+ð
˜Ÿ™ð 
¨%¯,©,ô 
ð à37ñ:Ø—‘ð:Ø,0ð:à	˜uÐ%AÑBÑ	Bô:ó ð:ñ8)˜Ÿ™ð )°Dð )ÀMÐTY×T`ÑT`ÑD`õ )ð àHLñ-Ø×"Ñ"ð-Ø15ð-à	˜×*Ñ*Ñ	*ô-ó ð-ð8˜Ÿ™ð ¨%¯,©,ð Àcð ÈeÏlÉlô ð˜Ÿ™ð ¨%¯,©,ð Àcð ÈeÏlÉlô ð.˜uŸ|™|ð .°·±ô .ñ`<:˜eŸl™lð <:¸ð <:ÐI\õ <:ñ|/)˜eŸl™lð /)¸ð /)ÈÐY^×YeÑYeÑIeõ /)ðh "'Ø Ø,0ñ")à—‘ð")ð ð")ð ð	")ð
 —?‘? TÑ)ð")ð 
˜Ÿ™Ñ	%õ")òJ9÷,Cð CrR   r   )#r@   rx   Útorch.nnr;   Úconfiguration_utilsr   r   Úloadersr   Úloaders.single_file_modelr   Úutilsr   Úutils.accelerate_utilsr	   Ú	attentionr   Úattention_processorr   r   r   r   r   r   Úmodeling_outputsr   Úmodeling_utilsr   Úvaer   r   r   r   r   r   © rR   rP   Ú<module>rë      sX   ðó ã Ý ç BÝ 'Ý ?Ý Ý 8Ý &÷÷ õ 3Ý 'ß `Õ `ôJCØÐ  .°+Ð?UÐWgõJCrR   