
    iu                     ^   d dl mZ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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 dd
lmZ ddlmZmZ ddlmZm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+  e%       rd dl,m-c m.Z/ dZ0ndZ0 e&jb                  e2      Z3dZ4d Z5ddZ6 G d de      Z7y)    )AnyCallableDictListOptionalUnionN)CLIPImageProcessorCLIPVisionModelWithProjectionT5EncoderModelT5TokenizerFast   )VaeImageProcessor)FluxLoraLoaderMixin)AutoencoderKL)BriaTransformer2DModel)DiffusionPipeline)BriaPipelineOutput)calculate_shiftretrieve_timesteps)DDIMSchedulerEulerAncestralDiscreteSchedulerFlowMatchEulerDiscreteSchedulerKarrasDiffusionSchedulers)USE_PEFT_BACKENDis_torch_xla_availableloggingreplace_example_docstringscale_lora_layersunscale_lora_layers)randn_tensorTFaC  
    Examples:
        ```py
        >>> import torch
        >>> from diffusers import BriaPipeline

        >>> pipe = BriaPipeline.from_pretrained("briaai/BRIA-3.2", torch_dtype=torch.bfloat16)
        >>> pipe.to("cuda")
        # BRIA's T5 text encoder is sensitive to precision. We need to cast it to bfloat16 and keep the final layer in float32.

        >>> pipe.text_encoder = pipe.text_encoder.to(dtype=torch.bfloat16)
        >>> for block in pipe.text_encoder.encoder.block:
        ...     block.layer[-1].DenseReluDense.wo.to(dtype=torch.float32)
        # BRIA's VAE is not supported in mixed precision, so we use float32.

        >>> if pipe.vae.config.shift_factor == 0:
        ...     pipe.vae.to(dtype=torch.float32)

        >>> prompt = "Photorealistic food photography of a stack of fluffy pancakes on a white plate, with maple syrup being poured over them. On top of the pancakes are the words 'BRIA 3.2' in bold, yellow, 3D letters. The background is dark and out of focus."
        >>> image = pipe(prompt).images[0]
        >>> image.save("bria.png")
        ```
c                     | d u xs> | dk(  xs7 t        | t              xr | d   d u xs t        |       t        k(  xr | d   dk(  S )N r   )
isinstancelisttype)negative_prompts    p/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/diffusers/pipelines/bria/pipeline_bria.py
is_ng_noner(   G   s`    4 	Hb 	H-L/!2D2L	H !T)Foa.@B.F	    c                     t        j                  d| | t         j                        d d d   j                         }|| z  }t        j                  d| dz
  |      D cg c]  }t	        |       }}||   }|S c c}w )N   dtyper   )nplinspacefloat32copyint)num_train_timestepsnum_inference_steps	timestepssigmasindinds
new_sigmass          r'   get_original_sigmasr;   P   s|    A24GrzzZ[_]_[_`eegI,,F "A/BQ/FH[ \]CH]D]J ^s   A8c            +          e Zd ZdZdZddgZddgZ	 	 d8ded	ee	e
f   d
ededededefdZ	 	 	 	 	 	 	 	 d9deeee   f   deej*                     dededeeeee   f      deej0                     deej0                     dedee   fdZed        Zed        Zed        Zej>                  d        Zed        Z ed        Z!	 	 	 	 	 d:d Z"	 	 	 	 d;deeee   f   dededeej*                     fd!Z#	 d<d"Z$e%d#        Z&e%d$        Z'e%d%        Z( ejR                          e*e+      dddd&dd'ddddddd(ddddgddd)fdeeee   f   d*ee   d+ee   d,ed-ee   d.edeeeee   f      dee   d/eeejX                  eejX                     f      deej0                     deej0                     deej0                     d0ee   d1ed2ee-ee.f      d3ee/eee-gdf      d4ee   ded5edef   d6ef(d7              Z0y)=BriaPipelineaU  
    Based on FluxPipeline with several changes:
    - no pooled embeddings
    - We use zero padding for prompts
    - No guidance embedding since this is not a distilled version

    Args:
        transformer ([`BriaTransformer2DModel`]):
            Conditional Transformer (MMDiT) architecture to denoise the encoded image latents.
        scheduler ([`FlowMatchEulerDiscreteScheduler`]):
            A scheduler to be used in combination with `transformer` to denoise the encoded image latents.
        vae ([`AutoencoderKL`]):
            Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
        text_encoder ([`T5EncoderModel`]):
            Frozen text-encoder. Bria uses
            [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel), specifically the
            [t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl) variant.
        tokenizer (`T5TokenizerFast`):
            Tokenizer of class
            [T5Tokenizer](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer).
    z=text_encoder->text_encoder_2->image_encoder->transformer->vaeimage_encoderfeature_extractorlatentsprompt_embedsNtransformer	schedulervaetext_encoder	tokenizerc           	         | j                  |||||||       t        | d      r8| j                  ,dt        | j                  j                  j
                        z  nd| _        t        | j                        | _        d| _	        | j                  j                  j                  Fd| j                  j                  _
        | j                  j                  t        j                         y y )	N)rD   rE   rF   rB   rC   r>   r?   rD         )vae_scale_factor@   r   r,   )register_moduleshasattrrD   lenconfigblock_out_channelsrJ   r   image_processordefault_sample_sizeshift_factortotorchr1   )selfrB   rC   rD   rE   rF   r>   r?   s           r'   __init__zBriaPipeline.__init__t   s     	%#'/ 	 	
 ?FdE>RW[W_W_WkA#dhhoo889:qs 	  1$BWBWX#% 88??''/+,DHHOO(HHKKemmK, 0r)   r+   T   promptdevicenum_images_per_promptdo_classifier_free_guidancer&   negative_prompt_embedsmax_sequence_length
lora_scalec
                    |xs | j                   }|	?t        | t              r/|	| _        | j                  t
        rt        | j                  |	       t        |t              r|gn|}|t        |      }
n|j                  d   }
|| j                  ||||      }|r|t        |      st        |t              r|
|gz  n|}|:t        |      t        |      ur$t        dt        |       dt        |       d      |
t        |      k7  r!t        d| dt        |       d| d|
 d		      | j                  ||||      }nt        j                   |      }| j                  ,t        | t              rt
        rt#        | j                  |	       t        j$                  |
|j                  d
   d      j'                  |      }|j)                  |d
d
      }|||fS )a)  

        Args:
            prompt (`str` or `List[str]`, *optional*):
                prompt to be encoded
            device: (`torch.device`):
                torch device
            num_images_per_prompt (`int`):
                number of images that should be generated per prompt
            do_classifier_free_guidance (`bool`):
                whether to use classifier free guidance or not
            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`).
            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, negative_prompt_embeds will be generated from `negative_prompt` input
                argument.
        r   )rY   r[   r^   rZ   z?`negative_prompt` should be the same type to `prompt`, but got z != .z`negative_prompt`: z has batch size z, but `prompt`: zT. Please make sure that passed `negative_prompt` matches the batch size of `prompt`.r+   r   rZ   )_execution_devicer#   r   _lora_scalerE   r   r   strrN   shape_get_t5_prompt_embedsr(   r%   	TypeError
ValueErrorrU   
zeros_liker   zerosrT   repeat)rV   rY   rZ   r[   r\   r&   rA   r]   r^   r_   
batch_sizetext_idss               r'   encode_promptzBriaPipeline.encode_prompt   s    F 1411 !j7J&K)D   ,1A!$"3"3Z@'4&&VJ&,,Q/J  66&;$7	 7 M '+A+Io.6@RU6VJ/!22\k   %$v,d?>S*S#YZ^_nZoYp q L>,   3#77$-o->>NsSbOcNd e"8#3J< @77  *.)C)C**?(;!	 *D *& */)9)9-)H&($ 349I#D$5$5zB;;z=+>+>q+A1EHHPVHW??#8!Q?4h>>r)   c                     | j                   S N_guidance_scalerV   s    r'   guidance_scalezBriaPipeline.guidance_scale   s    ###r)   c                      | j                   dkD  S )Nr+   rr   rt   s    r'   r\   z(BriaPipeline.do_classifier_free_guidance   s    ##a''r)   c                     | j                   S rq   _attention_kwargsrt   s    r'   attention_kwargszBriaPipeline.attention_kwargs   s    %%%r)   c                     || _         y rq   rx   )rV   values     r'   rz   zBriaPipeline.attention_kwargs  s
    !&r)   c                     | j                   S rq   )_num_timestepsrt   s    r'   num_timestepszBriaPipeline.num_timesteps  s    """r)   c                     | j                   S rq   )
_interruptrt   s    r'   	interruptzBriaPipeline.interrupt
  s    r)   c	           
          | j                   dz  z  dk7  s| j                   dz  z  dk7  r,t        j                  d j                   dz   d| d| d       |Lt         fd|D              s8t	        d j
                   d	|D 	cg c]  }	|	 j
                  vs|	 c}	       ||t	        d
| d| d      ||t	        d      |7t        |t              s't        |t              st	        dt        |             ||t	        d| d| d      |A|?|j                  |j                  k7  r&t	        d|j                   d|j                   d      ||dkD  rt	        d|       y y c c}	w )NrH   r   z-`height` and `width` have to be divisible by z	 but are z and z(. Dimensions will be resized accordinglyc              3   :   K   | ]  }|j                   v   y wrq   )_callback_tensor_inputs).0krV   s     r'   	<genexpr>z,BriaPipeline.check_inputs.<locals>.<genexpr>  s#      F
23A---F
s   z2`callback_on_step_end_tensor_inputs` has to be in z, but found z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 z'Cannot forward both `negative_prompt`: z and `negative_prompt_embeds`: zu`prompt_embeds` and `negative_prompt_embeds` must have the same shape when passed directly, but got: `prompt_embeds` z != `negative_prompt_embeds` ra   i   z8`max_sequence_length` cannot be greater than 512 but is )rJ   loggerwarningallri   r   r#   re   r$   r%   rf   )
rV   rY   heightwidthr&   rA   r]   "callback_on_step_end_tensor_inputsr^   r   s
   `         r'   check_inputszBriaPipeline.check_inputs  sK    T**Q./14AVAVYZAZ8[_`8`NN?@U@UXY@Y?ZZcdjckkpqvpw  x`  a .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  -";08N}o ^0 0  ^ 5w  FC)@TZ\`IaQRVW]R^Q_`aa&+A+M9/9J K*++]_ 
 $)?)K""&<&B&BB --:-@-@,A B.445Q8  */BS/HWXkWlmnn 0I*; pHs   E4E4c                    | j                   }| j                  }|xs |j                  }t        |t              r|gn|}t        |      }g }|D ])  }	 ||	|ddd      }
|
j                  } ||dd      j                  }|j                  d   |j                  d   k\  rNt        j                  ||      s8|j                  |d d |dz
  df         }t        j                  d| d	|         ||j                  |            d
   }|j                  \  }}}||k  rKt        j                  |||z
  |f|j                  |j                        }t        j                   ||gd      }|j#                  |       , t        j                   |d
      }|j                  |      }|j%                  d|d      }|j'                  ||z  |d      }|j                  | j(                  j                        }|S )NTpt)
max_length
truncationadd_special_tokensreturn_tensorslongest)paddingr   r.   r+   zXThe following part of your input was truncated because `max_sequence_length` is set to  z	 tokens: r   )r-   rZ   dimrb   r,   )rF   rE   rZ   r#   re   rN   	input_idsrf   rU   equalbatch_decoder   r   rT   rk   r-   concatappendrl   viewrB   )rV   rY   r[   r^   rZ   rF   rE   rm   prompt_embeds_listptext_inputstext_input_idsuntruncated_idsremoved_textrA   bseq_lenr   r   s                      r'   rg   z"BriaPipeline._get_t5_prompt_embedsA  s    NN	((.<..'4&&[
 	5A#.#'#K )22N'	RVWaaO$$R(N,@,@,DDU[[N  )55oaI\_`I`ceIeFe6fg+,Il^E
 )):):6)BCAFM ,11OAw,,+++g5s;=CVCV_l_s_s !&mW-E1 M%%m4=	5@ %7Q?%(((7 &,,Q0EqI%**:8M+MObdfg%((t/?/?/E/E(Fr)   c	                    dt        |      | j                  z  z  }dt        |      | j                  z  z  }||||f}	|0| j                  ||dz  |dz  ||      }
|j                  ||      |
fS t	        |t
              r)t        |      |k7  rt        dt        |       d| d      t        |	|||      }| j                  |||||      }| j                  ||dz  |dz  ||      }
||
fS )NrH   rZ   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.)	generatorrZ   r-   )
r3   rJ   _prepare_latent_image_idsrT   r#   r$   rN   ri   r    _pack_latents)rV   rm   num_channels_latentsr   r   r-   rZ   r   r@   rf   latent_image_idss              r'   prepare_latentszBriaPipeline.prepare_latentsx  s.    c&kT%:%::;SZ4#8#889165A#==j&TU+W\`aWacikpq::V5:9;KKKi&3y>Z+GA#i.AQ R&<'gi 
 u	&PUV$$Wj:NPVX]^99*fPQkSX\]S]_eglm(((r)   c                     | j                  |||dz  d|dz  d      } | j                  dddddd      } | j                  ||dz  |dz  z  |dz        } | S )NrH   r      r+   r      )r   permutereshape)r@   rm   r   r   r   s        r'   r   zBriaPipeline._pack_latents  sj    ,,z+?1aQVZ[Q[]^_//!Q1a3//*v{uz.JL`cdLder)   c                     | j                   \  }}}||z  }||z  }| j                  ||||dz  dd      } | j                  dddddd      } | j                  ||dz  |dz  |dz        } | S )Nr   rH   r   r   r+   r   )rf   r   r   r   )r@   r   r   rJ   rm   num_patcheschannelss          r'   _unpack_latentszBriaPipeline._unpack_latents  s    ,3MM)
K++)),,z65(a-AN//!Q1a3//*h5.A6A:uWXyYr)   c                 ^   t        j                  ||d      }|d   t        j                  |      d d d f   z   |d<   |d   t        j                  |      d d d f   z   |d<   |j                  \  }}}|j	                  | ddd      }|j                  | ||z  |      }|j                  ||      S )Nr   ).r+   ).rH   r+   r   )rU   rk   arangerf   rl   r   rT   )	rm   r   r   rZ   r-   r   latent_image_id_heightlatent_image_id_widthlatent_image_id_channelss	            r'   r   z&BriaPipeline._prepare_latent_image_ids  s     ;;vua8#3F#;ell6>RSTVZSZ>[#[ #3F#;ell5>QRVXYRY>Z#Z RbRhRhO 57O+22:q!QG+33.1FFH`
  ""&">>r)      r   pilFr   r   r5   r6   ru   r   output_typereturn_dictrz   callback_on_step_endr   
clip_value	normalizec                 t   |xs | j                   | j                  z  }|xs | j                   | j                  z  }| j                  ||||||       || _        || _        d| _        |t        |t              rd}n-|t        |t              rt        |      }n|j                  d   }| j                  }| j                  | j                  j                  dd      nd}| j                  ||| j                  ||||||	      \  }}}| j                  rt        j                   ||gd      }| j"                  j$                  j&                  d	z  }| j)                  ||z  ||||j*                  ||	|
      \  }
}t        | j,                  t.              r| j,                  j$                  d
   rt1        j2                  dd|z  |      }|
j                  d   }t5        || j,                  j$                  j6                  | j,                  j$                  j8                  | j,                  j$                  j:                  | j,                  j$                  j<                        }t?        | j,                  |||||      \  }}nt        | j,                  t@              st        | j,                  tB              rt?        | j,                  ||dd      \  }}nHtE        | j,                  j$                  jF                  |      }t?        | j,                  ||||      \  }}tI        t        |      || j,                  jJ                  z  z
  d      }t        |      | _&        t        |j                        dk(  r|d   }t        |j                        dk(  r|d   }| jO                  |      5 }tQ        |      D ]m  \  } }!| jR                  r| j                  rt        j                   |
gdz        n|
}"tU        | j,                        t.        k7  r| j,                  jW                  |"|!      }"|!jY                  |"j                  d         }#| j#                  |"|#|| j                  d||      d   }$| j                  r9|$j[                  d      \  }%}&|&j]                         }'|%| j^                  |&|%z
  z  z   }$|r|$d'|$j]                         z  z  z  d|$z  z   }$|r|dkD  sJ |$ja                  | |      }$|
j*                  }(| j,                  jc                  |$|!|
d      d   }
|
j*                  |(k7  r9t        jd                  jf                  ji                         r|
jk                  |(      }
|Zi })|D ]  }*tm               |*   |)|*<     || | |!|)      }+|+jo                  d|
      }
|+jo                  d|      }|+jo                  d|      }| t        |      dz
  k(  s'| dz   |kD  r/| dz   | j,                  jJ                  z  dk(  r|jq                          tr        sZtu        jv                          p 	 ddd       |dk(  r|
},n| jy                  |
||| j                        }
|
jk                  t        jz                        | j|                  j$                  j~                  z  | j|                  j$                  j                  z   }
| j|                  j                  |
jk                  | j|                  j*                        d      d   },| j                  j                  |,|      },| j                          |s|,fS t        |,      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.
            height (`int`, *optional*, defaults to self.unet.config.sample_size * self.vae_scale_factor):
                The height in pixels of the generated image. This is set to 1024 by default for the best results.
            width (`int`, *optional*, defaults to self.unet.config.sample_size * self.vae_scale_factor):
                The width in pixels of the generated image. This is set to 1024 by default for the best results.
            num_inference_steps (`int`, *optional*, defaults to 50):
                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 5.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.
            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_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.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 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, negative_prompt_embeds will be generated from `negative_prompt` input
                argument.
            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.bria.BriaPipelineOutput`] instead of a plain tuple.
            attention_kwargs (`dict`, *optional*):
                A kwargs dictionary that if specified is passed along to the `AttentionProcessor` as defined under
                `self.processor` in
                [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py).
            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: DiffusionPipeline, step: int, timestep: int,
                callback_kwargs: Dict)`. `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 variables listed in the
                `._callback_tensor_inputs` attribute of your pipeline class.
            max_sequence_length (`int` defaults to 256): Maximum sequence length to use with the `prompt`.

        Examples:

          Returns:
            [`~pipelines.bria.BriaPipelineOutput`] or `tuple`: [`~pipelines.bria.BriaPipelineOutput`] if `return_dict`
            is True, otherwise a `tuple`. When returning a tuple, the first element is a list with the generated
            images.
        )rY   r   r   rA   r   r^   FNr+   r   scale)	rY   r&   r\   rA   r]   rZ   r[   r^   r_   r   r   use_dynamic_shiftingg      ?)mu)r4   r5   )r7   r   )totalrH   )hidden_statestimestepencoder_hidden_statesrz   r   txt_idsimg_idsgffffff?g333333?)r   r@   rA   r]   latentr,   )r   )images)FrR   rJ   r   rs   rz   r   r#   re   r$   rN   rf   rc   getro   r\   rU   catrB   rO   in_channelsr   r-   rC   r   r/   r0   r   base_image_seq_lenmax_image_seq_len
base_shift	max_shiftr   r   r   r;   r4   maxorderr~   progress_bar	enumerater   r%   scale_model_inputexpandchunkstdru   clipstepbackendsmpsis_availablerT   localspopupdateXLA_AVAILABLExm	mark_stepr   r1   rD   scaling_factorrS   decoderQ   postprocessmaybe_free_model_hooksr   )-rV   rY   r   r   r5   r6   ru   r&   r[   r   r@   rA   r]   r   r   rz   r   r   r^   r   r   rm   rZ   r_   rn   r   r   r7   image_seq_lenr   num_warmup_stepsr   itlatent_model_inputr   
noise_prednoise_pred_uncondnoise_pred_textcfg_noise_pred_textlatents_dtypecallback_kwargsr   callback_outputsimages-                                                r'   __call__zBriaPipeline.__call__  s   B K433d6K6KKI11D4I4II 	'/Q 3 	 	
  . 0 *VS"9JJvt$<VJ&,,Q/J''AEAVAVAbT**..w=hl
<@<N<N+(,(H(H'#9"7 3! =O 
=
9. ++!II'=}&MSTUM  $//66BBaG$($8$8.. 	%
!! t~~'FG%%&<=[[a*=&=?RSF#MM!,M %%88%%77%%00%%//B .@#.*I* $..-8J ?= 2DNN$7t2.	. -(,(=(=(Q(Q(; 2DNN$7SY2.	. s9~0CdnnFZFZ0ZZ\]^!)n%%&!+/2x~~!#{H %89 =	#\!), <#1>> BFAaAaUYYy1}%=gn"'+JJ)-)I)IJ\^_)`& 88$6$<$<Q$?@ "--"4%*7%)%:%: %$, .  
 339C9I9I!9L6%*9*=*=*?'!2T5H5HO^oLo5p!pJ!+s6IJNNL\6\/]!^adgqaq!qJ%>)>!+*j!IJ !(..--j!WRW-XYZ[==M1~~))668")**]";'3&(O? 9-3Xa[*9';D!Q'X$.229gFG$4$8$8-$XM-=-A-ABZ\r-s* I**A9I/IqSTuX\XfXfXlXlNlpqNq '') LLNy<#=	#~ ("E **7FE4CXCXYGzzz69W9WW[_[c[c[j[j[w[wwGHHOOGJJTXX^^J$DRWOXYZ[E((44U4TE 	##%8O!//]=	# =	#s   I$\-\--\7)NN)Nr+   TNNNrX   N)NNNNN)Nr+   rX   Nrq   )1__name__
__module____qualname____doc__model_cpu_offload_seq_optional_componentsr   r   r   r   r   r   r   r   r
   r	   rW   re   r   r   rU   rZ   r3   boolFloatTensorfloatro   propertyru   r\   rz   setterr   r   r   rg   r   staticmethodr   r   r   no_gradr   EXAMPLE_DOC_STRING	Generatorr   r   r   r    r)   r'   r=   r=   Y   s\   , \+-@A(/: 8<04-+- 8:SST- 	-
 %- #- 5- .-B *.%&,0;?59>B#&&*_?c49n%_? &_?  #	_?
 &*_? "%T#Y"78_?   1 12_? !)):): ;_? !_? UO_?B $ $ ( ( & & ' ' # #   #+/ 1oj )-%&#&)-5c49n%5  #5 !	5
 &5@ !)F     ? ? U]]_12 )- $##%# !;?/0MQ/359>B%* 59KO9B#&)-+W0c49n%W0 W0 }	W0
 !W0 9W0 W0 "%T#Y"78W0  (}W0 E%//43H"HIJW0 %++,W0   1 12W0 !)):): ;W0 c]W0 W0  #4S>2!W0" 'xc40@$0F'GH#W0$ -1I%W0& !'W0( $+&)W0* +W0 3 W0r)   r=   )  r  )8typingr   r   r   r   r   r   numpyr/   rU   transformersr	   r
   r   r   rQ   r   loadersr   modelsr   $models.transformers.transformer_briar   	pipelinesr   pipelines.bria.pipeline_outputr   pipelines.flux.pipeline_fluxr   r   
schedulersr   r   r   r   utilsr   r   r   r   r   r   utils.torch_utilsr    torch_xla.core.xla_modelcore	xla_modelr   r   
get_loggerr   r   r
  r(   r;   r=   r  r)   r'   <module>r     s    = =    1 * # J * @ O   . ))MM 
		H	% 2@
0$ @
0r)   