
    
3j%                     N   S SK Jr  S SKJr  S SKrS SKrS SKJr  S SK	J
r
  S SKJrJr  SSKJr  SS	KJrJr  SS
KJr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%\RL                  " \'5      r(Sr)\ " S S\5      5       r* " S S\5      r+g)    )	dataclass)AnyN)Image)tqdm)CLIPTextModelCLIPTokenizer   )PipelineImageInput)AutoencoderKLUNet2DConditionModel)DDIMSchedulerLCMScheduler)
BaseOutputis_torch_xla_availableloggingreplace_example_docstring)randn_tensor   )DiffusionPipeline   )MarigoldImageProcessorTFa  
Examples:
```py
>>> import diffusers
>>> import torch

>>> pipe = diffusers.MarigoldNormalsPipeline.from_pretrained(
...     "prs-eth/marigold-normals-v1-1", variant="fp16", torch_dtype=torch.float16
... ).to("cuda")

>>> image = diffusers.utils.load_image("https://marigoldmonodepth.github.io/images/einstein.jpg")
>>> normals = pipe(image)

>>> vis = pipe.image_processor.visualize_normals(normals.prediction)
>>> vis[0].save("einstein_normals.png")
```
c                       \ rS rSr% Sr\R                  \R                  -  \	S'   S\R                  -  \R                  -  \	S'   S\R                  -  \	S'   Sr
g)MarigoldNormalsOutputM   u7  
Output class for Marigold monocular normals prediction pipeline.

Args:
    prediction (`np.ndarray`, `torch.Tensor`):
        Predicted normals with values in the range [-1, 1]. The shape is `numimages × 3 × height × width` for
        `torch.Tensor` or `numimages × height × width × 3` for `np.ndarray`.
    uncertainty (`None`, `np.ndarray`, `torch.Tensor`):
        Uncertainty maps computed from the ensemble, with values in the range [0, 1]. The shape is `numimages × 1 ×
        height × width` for `torch.Tensor` or `numimages × height × width × 1` for `np.ndarray`.
    latent (`None`, `torch.Tensor`):
        Latent features corresponding to the predictions, compatible with the `latents` argument of the pipeline.
        The shape is `numimages * numensemble × 4 × latentheight × latentwidth`.

predictionNuncertaintylatent )__name__
__module____qualname____firstlineno____doc__npndarraytorchTensor__annotations____static_attributes__r       p/home/wildlama/miniconda3/lib/python3.13/site-packages/diffusers/pipelines/marigold/pipeline_marigold_normals.pyr   r   M   sC     

U\\))

"U\\115<<r*   r   c            !       0  ^  \ rS rSrSrSrSr    S,S\S\S\	\
-  S	\S
\S\S-  S\S-  S\S-  S\S-  4U 4S jjjrS\S\S\S\S\S\S\S\\\4   S-  S\R*                  S-  S\R,                  \\R,                     -  S-  S\S\S\4S jr\R2                  R4                  S-S j5       r\R8                  " 5       \" \5                    S.S\S\S-  S\S\S-  S\S\S\S\S\\\4   S-  S\R*                  \\R*                     -  S-  S\R,                  \\R,                     -  S-  S\S\S \S!\4S" jj5       5       rS\R*                  S\R*                  S-  S\R,                  S-  S\S\S\ \R*                  \R*                  4   4S# jr!S$\R*                  S\R*                  4S% jr"\#S/S&\R*                  S'\$S\R*                  4S( jj5       r%\# S0S&\R*                  S\S)\S\ \R*                  \R*                  S-  4   4S* jj5       r&S+r'U =r($ )1MarigoldNormalsPipelinec   a  
Pipeline for monocular normals estimation using the Marigold method: https://marigoldmonodepth.github.io.

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:
    unet (`UNet2DConditionModel`):
        Conditional U-Net to denoise the normals latent, conditioned on image latent.
    vae (`AutoencoderKL`):
        Variational Auto-Encoder (VAE) Model to encode and decode images and predictions to and from latent
        representations.
    scheduler (`DDIMScheduler` or `LCMScheduler`):
        A scheduler to be used in combination with `unet` to denoise the encoded image latents.
    text_encoder (`CLIPTextModel`):
        Text-encoder, for empty text embedding.
    tokenizer (`CLIPTokenizer`):
        CLIP tokenizer.
    prediction_type (`str`, *optional*):
        Type of predictions made by the model.
    use_full_z_range (`bool`, *optional*):
        Whether the normals predicted by this model utilize the full range of the Z dimension, or only its positive
        half.
    default_denoising_steps (`int`, *optional*):
        The minimum number of denoising diffusion steps that are required to produce a prediction of reasonable
        quality with the given model. This value must be set in the model config. When the pipeline is called
        without explicitly setting `num_inference_steps`, the default value is used. This is required to ensure
        reasonable results with various model flavors compatible with the pipeline, such as those relying on very
        short denoising schedules (`LCMScheduler`) and those with full diffusion schedules (`DDIMScheduler`).
    default_processing_resolution (`int`, *optional*):
        The recommended value of the `processing_resolution` parameter of the pipeline. This value must be set in
        the model config. When the pipeline is called without explicitly setting `processing_resolution`, the
        default value is used. This is required to ensure reasonable results with various model flavors trained
        with varying optimal processing resolution values.
ztext_encoder->unet->vae)normalsNunetvae	schedulertext_encoder	tokenizerprediction_typeuse_full_z_rangedefault_denoising_stepsdefault_processing_resolutionc
                   > [         T
U ]  5         X`R                  ;  a&  [        R	                  SU SU R                   S35        U R                  UUUUUS9  U R                  UUUU	S9  [        U SS 5      (       a/  S[        U R                  R                  R                  5      S-
  -  OS	U l        Xpl        Xl        Xl        S U l        [#        U R                  S
9U l        g )Nz*Potentially unsupported `prediction_type='z&'`; values supported by the pipeline: .)r0   r1   r2   r3   r4   )r5   r6   r7   r8   r1   r   r      )vae_scale_factor)super__init__supported_prediction_typesloggerwarningregister_modulesregister_to_configgetattrlenr1   configblock_out_channelsr<   r6   r7   r8   empty_text_embeddingr   image_processor)selfr0   r1   r2   r3   r4   r5   r6   r7   r8   	__class__s             r+   r>    MarigoldNormalsPipeline.__init__   s     	"A"AANN<_<MMs22316
 	% 	 	
 	+-$;*G	 	  	
 W^^bdikoVpVpc$((//*L*L&MPQ&Q Rvw 0'>$-J*$(!5tG\G\]r*   imagenum_inference_stepsensemble_sizeprocessing_resolutionresample_method_inputresample_method_output
batch_sizeensembling_kwargslatents	generatoroutput_typeoutput_uncertaintyreturnc           
      H	  ^
 S[        U R                  R                  R                  5      S-
  -  nXR                  :w  a  [        SU R                   SU S35      eUc  [        S5      eUS:  a  [        S5      eUS:  a  [        S5      eUS:X  a  [        R                  S	5        US:X  a  U(       a  [        S
5      eUc  [        S5      eUS:  a  [        S5      eX@R                  -  S:w  a  [        SU R                   S35      eUS;  a  [        S5      eUS;  a  [        S5      eUS:  a  [        S5      eUS;  a  [        S5      eU	b  T
b  [        S5      eUb:  [        U[        5      (       d  [        S5      eSU;   a  US   S;  a  [        S5      eSnSu  nn[        U[        5      (       d  U/n[        U5       GH  u  nn[        U[        R                  5      (       d  [        R                  " U5      (       a`  UR                   S;  a  [        SU SUR"                   S35      eUR"                  SS  u  nnSnUR                   S :X  a  UR"                  S   nOL[        U[$        R$                  5      (       a  UR&                  u  nnSnO[        S!U S"[)        U5       S35      eUc  UUnnO"UU4UU4:w  a  [        S#U S$UU4 S%UU4 35      eUU-  nGM     U	Gb%  [        R                  " U	5      (       d  [        S&5      eU	R+                  5       S :w  a  [        S'U	R"                   S35      eUS:  a=  [-        UU5      nUU-  U-  nX-  U-  nUS:X  d  US:X  a  [        S(U S)U S*35      eUUnnXR                  -   S-
  U R                  -  nUU R                  -   S-
  U R                  -  nX-  U R                  R                  R.                  UU4nU	R"                  U:w  a  [        S+U	R"                   S,U S35      eT
b  [        T
[        5      (       aD  [        T
5      X-  :w  a  [        S-5      e[1        U
4S. jT
 5       5      (       d  [        S/5      e U$ [        T
[        R2                  5      (       d  [        S0[)        T
5       S35      eU$ )1Nr   r   z/`vae_scale_factor` computed at initialization (z) differs from the actual one (z).zW`num_inference_steps` is not specified and could not be resolved from the model config.z'`num_inference_steps` must be positive.z!`ensemble_size` must be positive.zk`ensemble_size` == 2 results are similar to no ensembling (1); consider increasing the value to at least 3.zpComputing uncertainty by setting `output_uncertainty=True` also requires setting `ensemble_size` greater than 1.zY`processing_resolution` is not specified and could not be resolved from the model config.r   zx`processing_resolution` must be non-negative: 0 for native resolution, or any positive value for downsampled processing.z.`processing_resolution` must be a multiple of r:   )nearestznearest-exactbilinearbicubicareazy`resample_method_input` takes string values compatible with PIL library: nearest, nearest-exact, bilinear, bicubic, area.zz`resample_method_output` takes string values compatible with PIL library: nearest, nearest-exact, bilinear, bicubic, area.z`batch_size` must be positive.)ptr$   z*`output_type` must be one of `pt` or `np`.z2`latents` and `generator` cannot be used together.z)`ensembling_kwargs` must be a dictionary.	reductionclosestmeanzG`ensembling_kwargs['reduction']` can be either `'closest'` or `'mean'`.)NN)r   r	      z`image[z(]` has unsupported dimensions or shape: rd   zUnsupported `image[z	]` type: zInput `image[z]` has incompatible dimensions z with the previous images z!`latents` must be a torch.Tensor.z/`latents` has unsupported dimensions or shape: z*Extreme aspect ratio of the input image: [z x ]z`latents` has unexpected shape=z
 expected=z^The number of generators must match the total number of ensemble members for all input images.c              3      >#    U  H4  oR                   R                  TS    R                   R                  :H  v   M6     g7f)r   N)devicetype).0grV   s     r+   	<genexpr>7MarigoldNormalsPipeline.check_inputs.<locals>.<genexpr>2  s,     Xi88==IaL,?,?,D,DDis   <?z;`generator` device placement is not consistent in the list.zUnsupported generator type: )rE   r1   rF   rG   r<   
ValueErrorr@   rA   
isinstancedictlist	enumerater$   r%   r&   	is_tensorndimshaper   sizeri   dimmaxlatent_channelsall	Generator)rJ   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   actual_vae_scale_factor
num_imagesWHiimgH_iW_iN_imax_orignew_Hnew_Wwhshape_expecteds             `                 r+   check_inputs$MarigoldNormalsPipeline.check_inputs   s2    #$DHHOO,N,N(ORS(S"T"&;&;;A$BWBWAXXw  yP  xQ  QS  T  &vww"FGG1@AAANN? A"4"  !(k  !1$*  !#8#88A=MdNcNcMddefgg (ccC  ")ddC  >=>>l*IJJ9#8QRR(/66 !LMM//4Ek4RZm4m !jkk 
1%&&GE&FAs#rzz**eooc.B.B889,$wqc1YZ]ZcZcYdde%fgg99RS>S88q=))A,CC--88S #6qc49+Q!OPPyC11QC:% #A3&EsCj\Qkmnpqlrkst  #J' ', ??7++ !DEE{{}! #RSZS`S`Raab!cdd$q(q!911X=1X=A:!$'QRSQTTWXYWZZ[%\]]e1***Q.43H3HHAT***Q.43H3HHA(8$((//:Y:Y[\^_`N}}. #B7==/Q[\j[kkl!mnn  )T**y>Z%??$x  XiXXX$%bcc Y
   	5??;; #?Y?PPQ!RSSr*   c                    [        U S5      (       d  0 U l        OA[        U R                  [        5      (       d"  [	        S[        U R                  5       S35      e[        S0 U R                  D6nUR                  SU5      US'   UR                  SU5      US'   Ub  [        U40 UD6$ Ub  [        SSU0UD6$ [	        S5      e)	N_progress_bar_configz=`self._progress_bar_config` should be of type `dict`, but is r:   descleavetotalz/Either `total` or `iterable` has to be defined.r   )hasattrr   ro   rp   rn   ri   getr   )rJ   iterabler   r   r   progress_bar_configs         r+   progress_bar$MarigoldNormalsPipeline.progress_bar9  s    t344(*D%D55t<<OPTUYUnUnPoOppqr  #?T%>%>?&9&=&=fd&KF#':'>'>w'NG$8$788;e;':;;NOOr*   match_input_resolutionoutput_latentreturn_dictc                 ~   U R                   nU R                  nUc  U R                  nUc  U R                  nU R	                  UUUUUUUU	U
UUU5      nU R
                  c]  SnU R                  USU R                  R                  SSS9nUR                  R                  U5      nU R                  U5      S   U l        U R                  R                  XUUU5      u  nnnU R                  XXU5      u  nnAU R
                  R                  UUS9R                  US	S	5      n/ nU R                  [!        SUU-  U5      SS
S9 H  nUUUU-    nUUUU-    nUR"                  S   nUSU n U R$                  R'                  UUS9  U R                  U R$                  R(                  SSS9 Hw  n![*        R,                  " UU/S	S9n"U R/                  U"U!U SS9S   n#U R$                  R1                  U#U!UUS9R2                  n[4        (       d  Mb  [6        R8                  " 5         My     UR;                  U5        M     [*        R,                  " USS9nAAAAAA A"A#[*        R,                  " [!        SUR"                  S   U5       Vs/ s H  nU R=                  UUUU-    5      PM     snSS9n$U(       d  SnU R                  R?                  U$U5      n$Sn%US	:  a  U$R@                  " UU/U$R"                  S	S Q76 n$[!        U5       Vs/ s H#  nU RB                  " U$U   U40 U	=(       d    0 D6PM%     n$n[E        U$6 u  n$n%[*        R,                  " U$SS9n$U(       a  [*        R,                  " U%SS9n%OSn%U(       aS  U R                  RG                  U$UUSS9n$U RI                  U$5      n$U%b#  U(       a  U R                  RG                  U%UUSS9n%US:X  a@  U R                  RK                  U$5      n$U%b"  U(       a  U R                  RK                  U%5      n%U RM                  5         U(       d  U$U%U4$ [O        U$U%US9$ s  snf s  snf )a  
Function invoked when calling the pipeline.

Args:
    image (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`),
        `list[torch.Tensor]`: An input image or images used as an input for the normals estimation task. For
        arrays and tensors, the expected value range is between `[0, 1]`. Passing a batch of images is possible
        by providing a four-dimensional array or a tensor. Additionally, a list of images of two- or
        three-dimensional arrays or tensors can be passed. In the latter case, all list elements must have the
        same width and height.
    num_inference_steps (`int`, *optional*, defaults to `None`):
        Number of denoising diffusion steps during inference. The default value `None` results in automatic
        selection.
    ensemble_size (`int`, defaults to `1`):
        Number of ensemble predictions. Higher values result in measurable improvements and visual degradation.
    processing_resolution (`int`, *optional*, defaults to `None`):
        Effective processing resolution. When set to `0`, matches the larger input image dimension. This
        produces crisper predictions, but may also lead to the overall loss of global context. The default
        value `None` resolves to the optimal value from the model config.
    match_input_resolution (`bool`, *optional*, defaults to `True`):
        When enabled, the output prediction is resized to match the input dimensions. When disabled, the longer
        side of the output will equal to `processing_resolution`.
    resample_method_input (`str`, *optional*, defaults to `"bilinear"`):
        Resampling method used to resize input images to `processing_resolution`. The accepted values are:
        `"nearest"`, `"nearest-exact"`, `"bilinear"`, `"bicubic"`, or `"area"`.
    resample_method_output (`str`, *optional*, defaults to `"bilinear"`):
        Resampling method used to resize output predictions to match the input resolution. The accepted values
        are `"nearest"`, `"nearest-exact"`, `"bilinear"`, `"bicubic"`, or `"area"`.
    batch_size (`int`, *optional*, defaults to `1`):
        Batch size; only matters when setting `ensemble_size` or passing a tensor of images.
    ensembling_kwargs (`dict`, *optional*, defaults to `None`)
        Extra dictionary with arguments for precise ensembling control. The following options are available:
        - reduction (`str`, *optional*, defaults to `"closest"`): Defines the ensembling function applied in
          every pixel location, can be either `"closest"` or `"mean"`.
    latents (`torch.Tensor`, *optional*, defaults to `None`):
        Latent noise tensors to replace the random initialization. These can be taken from the previous
        function call's output.
    generator (`torch.Generator`, or `list[torch.Generator]`, *optional*, defaults to `None`):
        Random number generator object to ensure reproducibility.
    output_type (`str`, *optional*, defaults to `"np"`):
        Preferred format of the output's `prediction` and the optional `uncertainty` fields. The accepted
        values are: `"np"` (numpy array) or `"pt"` (torch tensor).
    output_uncertainty (`bool`, *optional*, defaults to `False`):
        When enabled, the output's `uncertainty` field contains the predictive uncertainty map, provided that
        the `ensemble_size` argument is set to a value above 2.
    output_latent (`bool`, *optional*, defaults to `False`):
        When enabled, the output's `latent` field contains the latent codes corresponding to the predictions
        within the ensemble. These codes can be saved, modified, and used for subsequent calls with the
        `latents` argument.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether or not to return a [`~pipelines.marigold.MarigoldNormalsOutput`] instead of a plain tuple.

Examples:

Returns:
    [`~pipelines.marigold.MarigoldNormalsOutput`] or `tuple`:
        If `return_dict` is `True`, [`~pipelines.marigold.MarigoldNormalsOutput`] is returned, otherwise a
        `tuple` is returned where the first element is the prediction, the second element is the uncertainty
        (or `None`), and the third is the latent (or `None`).
N 
do_not_padTr_   )padding
max_length
truncationreturn_tensorsr   )rh   dtyper   zMarigold predictions...)r   r   )rh   FzDiffusion steps...rw   )encoder_hidden_statesr   )rV   )is_aar$   )r   r   r   )(_execution_devicer   r7   r8   r   rH   r4   model_max_length	input_idstor3   rI   
preprocessprepare_latentsrepeatr   rangeru   r2   set_timesteps	timestepsr&   catr0   stepprev_sampleXLA_AVAILABLExm	mark_stepappenddecode_predictionunpad_imagereshapeensemble_normalszipresize_antialiasnormalize_normalspt_to_numpymaybe_free_model_hooksr   )&rJ   rM   rN   rO   rP   r   rQ   rR   rS   rT   rU   rV   rW   rX   r   r   rh   r   r}   prompttext_inputstext_input_idsr   original_resolutionimage_latentpred_latentbatch_empty_text_embeddingpred_latentsr   batch_image_latentbatch_pred_latenteffective_batch_sizetexttbatch_latentnoiser   r   s&                                         r+   __call__ MarigoldNormalsPipeline.__call__L  s   d ''

 &"&">"> ($($F$F! &&!!"

" $$,F..$>>::# ) K )2255f=N(,(9(9.(I!(LD% /3.B.B.M.M*?/
+w+ %)$8$8Ij%
!k %)%>%>%A%AW\%A%]%d%d1&
" ""!Z-/<DOh # 
A ".a!j.!A +AJ ?#5#;#;A#> -.C/CDDNN(()<V(L&&t~~'?'?uSg&h$yy*<>O)PVWX		,[`	abcd$(NN$7$71/9 %8 %+ " !=LLN i  12'
* ii!4 & YY q+"3"3A"6
CCA &&{1q:~'FGC 

 K ))55j'J
 1#++J]
HXHXYZY[H\]J z**A %%jm5GeL]Lcace*   '*:&6#J:15J!#ii;" "-->>/1Gu ? J //
;J&+="22CC!46LTY D 
 $--99*EJ&+="22>>{K 	##%[99$!#
 	
w*s   !P5*P:c                    S n[         R                  " [        SUR                  S   U5       Vs/ s H(  nU" U R                  R                  XXu-    5      5      PM*     snSS9nXR                  R                  R                  -  nUR                  USS9nUn	U	c*  [        UR                  UUR                  UR                  S9n	X4$ s  snf )Nc                     [        U S5      (       a  U R                  R                  5       $ [        U S5      (       a  U R                  $ [	        S5      e)Nlatent_distrU   z3Could not access latents of provided encoder_output)r   r   moderU   AttributeError)encoder_outputs    r+   retrieve_latentsAMarigoldNormalsPipeline.prepare_latents.<locals>.retrieve_latents[  sI    ~}55%11668833%---$%Z[[r*   r   r   )rV   rh   r   )r&   r   r   ru   r1   encoderF   scaling_factorrepeat_interleaver   rh   r   )
rJ   rM   rU   rV   rO   rS   r   r   r   r   s
             r+   r   'MarigoldNormalsPipeline.prepare_latentsS  s    	\ yy q%++a.*==A !1>1J!KL= 
 $hhoo&D&DD#55m5K&""##**"((	K ((%s   /C	r   c                 N   UR                  5       S:w  d1  UR                  S   U R                  R                  R                  :w  a:  [        SU R                  R                  R                   SUR                   S35      eU R                  R                  XR                  R                  R                  -  SS9S   n[        R                  " US	S
5      nU R                  (       d.  US S 2SS S 2S S 24==   S-  ss'   US S 2SS S 2S S 24==   S-  ss'   U R                  U5      nU$ )Nrd   r   z Expecting 4D tensor of shape [B,z,H,W]; got r:   F)r   r   g      g      ?r   g      ?)rw   ru   r1   rF   ry   rn   decoder   r&   clipr6   r   )rJ   r   r   s      r+   r   )MarigoldNormalsPipeline.decode_predictionx  s    ??![%6%6q%9TXX__=\=\%\2488??3R3R2SS^_j_p_p^qqrs  XX__[88??3Q3Q%Q_d_efgh
ZZ
D#6
$$q!Qz"c)"q!Qz"c)"++J7
r*   r/   epsc                     U R                  5       S:w  d  U R                  S   S:w  a  [        SU R                   S35      e[        R                  " U SSS9nXR                  US9-  n U $ )	Nrd   r   r	   ,Expecting 4D tensor of shape [B,3,H,W]; got r:   Trw   keepdim)min)rw   ru   rn   r&   normclamp)r/   r   r   s      r+   r   )MarigoldNormalsPipeline.normalize_normals  sd    ;;=Aq!1Q!6KGMM?Z[\]]zz'q$7::#:&&r*   r`   c                 B   U R                  5       S:w  d  U R                  S   S:w  a  [        SU R                   S35      eUS;  a  [        SU S35      eU R                  SS	S
9n[        R                  U5      nX0-  R                  SS	S
9nUR                  SS5      nSnU(       a1  UR                  5       nUR                  SS	S
9[        R                  -  nUS:X  a  X54$ UR                  SS	S
9nUR                  SSSS5      n[        R                  " U SU5      nXu4$ )a  
Ensembles the normals maps represented by the `normals` tensor with expected shape `(B, 3, H, W)`, where B is
the number of ensemble members for a given prediction of size `(H x W)`.

Args:
    normals (`torch.Tensor`):
        Input ensemble normals maps.
    output_uncertainty (`bool`, *optional*, defaults to `False`):
        Whether to output uncertainty map.
    reduction (`str`, *optional*, defaults to `"closest"`):
        Reduction method used to ensemble aligned predictions. The accepted values are: `"closest"` and
        `"mean"`.

Returns:
    A tensor of aligned and ensembled normals maps with shape `(1, 3, H, W)` and optionally a tensor of
    uncertainties of shape `(1, 1, H, W)`.
rd   r   r	   r   r:   ra   zUnrecognized reduction method: r   Tr   Nrc   )rw   ru   rn   rc   r-   r   sumr   arccosr$   piargmaxr   r&   gather)r/   rX   r`   mean_normalssim_cosr   closest_indicesclosest_normalss           r+   r   (MarigoldNormalsPipeline.ensemble_normals  s*   * ;;=Aq!1Q!6KGMM?Z[\]]//>ykKLL||4|8.@@N)..1d.C--A&!..*K%**q$*?"%%GK,,!..Q.=)00Aq!<,,w?C++r*   )r   r7   r8   rH   rI   r6   r<   )NTNN)NNNT)Nr   NTr\   r\   r   NNNr$   FFT)gư>)rb   ))r   r    r!   r"   r#   model_cpu_offload_seqr?   r   r   r   r   r   r   strboolintr>   r
   rp   r   r&   r'   r{   rq   r   compilerdisabler   no_gradr   EXAMPLE_DOC_STRINGr   tupler   r   staticmethodfloatr   r   r)   __classcell__)rK   s   @r+   r-   r-   c   s   "H 6!- '+(,.248*^"*^ *^ !</	*^
 $*^ !*^ t*^ +*^ "%t*^ (+Tz*^ *^X@!@ !@ 	@
  #@  #@ !$@ @  S>D0@ $@ ??T%//%::TA@ @ !@ 
@D ^^P P$ ]]_12 +/,0'+%/&037<@DH#(# !B
!B
 !4ZB
 	B

  #TzB
 !%B
  #B
 !$B
 B
  S>D0B
 U\\ 22T9B
 ??T%//%::TAB
 B
 !B
 B
  !B
 3 B
J#)||#) $#) ??T)	#)
 #) #) 
u||U\\)	*#)JU\\ ell $ 5<< e u||   JS+,+,37+,DG+,	u||U\\D00	1+, +,r*   r-   ),dataclassesr   typingr   numpyr$   r&   PILr   	tqdm.autor   transformersr   r   rI   r
   modelsr   r   
schedulersr   r   utilsr   r   r   r   utils.torch_utilsr   pipeline_utilsr   marigold_image_processingr   torch_xla.core.xla_modelcore	xla_modelr   r   
get_loggerr   r@   r   r   r-   r   r*   r+   <module>r     s   & "      5 1  . . = ))MM			H	% &  J    *]	,/ ]	,r*   