o
    Giw                  	   @   s\  d dl Z d dlmZmZ d dlZd dlZd dlZd dl	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mZ dd	lm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$ e rud dl%m&  m'Z( dZ)ndZ)e*e+Z,e rd dl-Z-dZ.dd Z/dd Z0dd Z1				d&de2de2d e3d!e3fd"d#Z4G d$d% d%e"eZ5dS )'    N)AnyCallable)AutoTokenizerUMT5EncoderModel   )MultiPipelineCallbacksPipelineCallback)PipelineImageInput)HeliosLoraLoaderMixin)AutoencoderKLWanHeliosTransformer3DModel)HeliosScheduler)is_ftfy_availableis_torch_xla_availableloggingreplace_example_docstring)randn_tensor)VideoProcessor   )DiffusionPipeline   )HeliosPipelineOutputTFa  
    Examples:
        ```python
        >>> import torch
        >>> from diffusers.utils import export_to_video
        >>> from diffusers import AutoencoderKLWan, HeliosPipeline

        >>> # Available models: BestWishYsh/Helios-Base, BestWishYsh/Helios-Mid, BestWishYsh/Helios-Distilled
        >>> model_id = "BestWishYsh/Helios-Base"
        >>> vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
        >>> pipe = HeliosPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
        >>> pipe.to("cuda")

        >>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
        >>> negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"

        >>> output = pipe(
        ...     prompt=prompt,
        ...     negative_prompt=negative_prompt,
        ...     height=384,
        ...     width=640,
        ...     num_frames=132,
        ...     guidance_scale=5.0,
        ... ).frames[0]
        >>> export_to_video(output, "output.mp4", fps=24)
        ```
c                 C   s"   t | } tt| } |  S N)ftfyfix_texthtmlunescapestriptext r    ^/home/ubuntu/.local/lib/python3.10/site-packages/diffusers/pipelines/helios/pipeline_helios.pybasic_cleanM   s   
r"   c                 C   s   t dd| } |  } | S )Nz\s+ )resubr   r   r    r    r!   whitespace_cleanS   s   r&   c                 C   s   t t| } | S r   )r&   r"   r   r    r    r!   prompt_cleanY   s   r'               ?ffffff?base_seq_lenmax_seq_len
base_shift	max_shiftc                 C   s,   || ||  }|||  }| | | }|S r   r    )image_seq_lenr,   r-   r.   r/   mbmur    r    r!   calculate_shift_   s   r4   c                G       s  e Zd ZdZdZg dZdgZdedede	de
def
 fd	d
Z					dbdeee B dededejdB dejdB f
ddZ								dcdeee B deee B dB dededejdB dejdB dedejdB dejdB fddZ					ddddZ			 	!				ded"ed#ed$ed%ed&edejdB dejdB d'ejeej B dB d(ejdB d)ejfd*d+Z					ddd,ejd-ejd.ejd/edejdB dejdB d'ejeej B dB d(ejdB d0ejdB d)ejfd1d2Z				dfd3ejd-ejd.ejd/edejdB dejdB d'ejeej B dB d(ejdB d)ejfd4d5Zed6d7 Zed8d9 Zed:d; Zed<d= Z ed>d? Z!ed@dA Z"e# e$e%dddd dBdCddDddddddEdddd(gdFdddddGdHddddGdHg dIdJddKf"deee B deee B d$ed%ed&edLedMee& dNe&dedB d'ejeej B dB d(ejdB dejdB dejdB dOedB dPedQe'ee(f dB dRe)eegdf e*B e+B dB dSee ded,e,dB dTejdB dUejdB dVedWe&dXe&d3e,dB dYejdB dZed[e&d\e&d]ed/ed^ed_efDd`daZ-  Z.S )gHeliosPipelinea  
    Pipeline for text-to-video / image-to-video / video-to-video generation using Helios.

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

    Args:
        tokenizer ([`T5Tokenizer`]):
            Tokenizer from [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5Tokenizer),
            specifically the [google/umt5-xxl](https://huggingface.co/google/umt5-xxl) variant.
        text_encoder ([`T5EncoderModel`]):
            [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), specifically
            the [google/umt5-xxl](https://huggingface.co/google/umt5-xxl) variant.
        transformer ([`HeliosTransformer3DModel`]):
            Conditional Transformer to denoise the input latents.
        scheduler ([`HeliosScheduler`]):
            A scheduler to be used in combination with `transformer` to denoise the encoded image latents.
        vae ([`AutoencoderKLWan`]):
            Variational Auto-Encoder (VAE) Model to encode and decode videos to and from latent representations.
    ztext_encoder->transformer->vae)latentsprompt_embedsnegative_prompt_embedstransformer	tokenizertext_encodervae	schedulerc                    sh   t    | j|||||d t| dd r| jjjnd| _t| dd r(| jjjnd| _	t
| j	d| _d S )N)r<   r;   r:   r9   r=   r<         )vae_scale_factor)super__init__register_modulesgetattrr<   configscale_factor_temporalvae_scale_factor_temporalscale_factor_spatialvae_scale_factor_spatialr   video_processor)selfr:   r;   r<   r=   r9   	__class__r    r!   rB      s   
zHeliosPipeline.__init__Nr      promptnum_videos_per_promptmax_sequence_lengthdevicedtypec              	      s  |p| j }|p
| jj}t|tr|gn|}dd |D }t|}| j|d ddddd}|j|j}}	|		dj
dd	 }
| |||	|j}|j||d
}dd t||
D }tj fdd|D dd	}|j\}}}|d|d}||| |d}||j fS )Nc                 S   s   g | ]}t |qS r    )r'   .0ur    r    r!   
<listcomp>   s    z8HeliosPipeline._get_t5_prompt_embeds.<locals>.<listcomp>
max_lengthTpt)paddingrX   
truncationadd_special_tokensreturn_attention_maskreturn_tensorsr   r   dim)rS   rR   c                 S   s   g | ]
\}}|d | qS r   r    )rU   rV   vr    r    r!   rW      s    c                    s2   g | ]}t || |d  |dgqS )r   r   )torchcat	new_zerossizerT   rQ   r    r!   rW      s   2 )_execution_devicer;   rS   
isinstancestrlenr:   	input_idsattention_maskgtsumlongtolast_hidden_stateziprb   stackshaperepeatviewbool)rK   rO   rP   rQ   rR   rS   
batch_sizetext_inputstext_input_idsmaskseq_lensr7   _seq_lenr    rf   r!   _get_t5_prompt_embeds   s4   
	z$HeliosPipeline._get_t5_prompt_embedsTnegative_promptdo_classifier_free_guidancer7   r8   c
              
   C   s  |p| j }t|tr|gn|}|durt|}
n|jd }
|du r-| j|||||	d\}}|r|du r|p6d}t|trA|
|g n|}|dur^t|t|ur^tdt| dt| d|
t|krwtd| d	t| d
| d	|
 d	| j|||||	d\}}||fS )a"  
        Encodes the prompt into text encoder hidden states.

        Args:
            prompt (`str` or `list[str]`, *optional*):
                prompt to be encoded
            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`).
            do_classifier_free_guidance (`bool`, *optional*, defaults to `True`):
                Whether to use classifier free guidance or not.
            num_videos_per_prompt (`int`, *optional*, defaults to 1):
                Number of videos that should be generated per prompt. torch device to place the resulting embeddings on
            prompt_embeds (`torch.Tensor`, *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.Tensor`, *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.
            device: (`torch.device`, *optional*):
                torch device
            dtype: (`torch.dtype`, *optional*):
                torch dtype
        Nr   )rO   rP   rQ   rR   rS    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`.)	rh   ri   rj   rk   ru   r   type	TypeError
ValueError)rK   rO   r   r   rP   r7   r8   rQ   rR   rS   ry   r~   r    r    r!   encode_prompt   sL   
&



zHeliosPipeline.encode_promptc
           
         sP  |d dks|d dkrt d| d| d|d ur8t fdd|D s8t d j d	 fd
d|D  |d urK|d urKt d| d| d|d ur^|d ur^t d| d| d|d u rj|d u rjt d|d urt|tst|tst dt| |d urt|tst|tst dt| |d ur|	d urt dd S d S )N   r   z8`height` and `width` have to be divisible by 16 but are z and r   c                 3   s    | ]}| j v V  qd S r   _callback_tensor_inputsrU   krK   r    r!   	<genexpr>$  s    

z.HeliosPipeline.check_inputs.<locals>.<genexpr>z2`callback_on_step_end_tensor_inputs` has to be in z, but found c                    s   g | ]	}| j vr|qS r    r   r   r   r    r!   rW   (  s    z/HeliosPipeline.check_inputs.<locals>.<listcomp>zCannot forward both `prompt`: z and `prompt_embeds`: z2. Please make sure to only forward one of the two.z'Cannot forward both `negative_prompt`: z and `negative_prompt_embeds`: 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;`negative_prompt` has to be of type `str` or `list` but is z1image and video cannot be provided simultaneously)r   allr   ri   rj   listr   )
rK   rO   r   heightwidthr7   r8   "callback_on_step_end_tensor_inputsimagevideor    r   r!   check_inputs  s>   zHeliosPipeline.check_inputsr       !   ry   num_channels_latentsr   r   
num_frames	generatorr6   returnc
                 C   s   |	d ur|	j ||dS |d | j d }
|||
t|| j t|| j f}t|tr=t||kr=tdt| d| dt||||d}	|	S )NrR   rS   r   z/You have passed a list of generators of length z+, but requested an effective batch size of z@. Make sure the batch size matches the length of the generators.)r   rR   rS   )	rq   rG   intrI   ri   r   rk   r   r   )rK   ry   r   r   r   r   rS   rR   r   r6   num_latent_framesru   r    r    r!   prepare_latentsC  s"   zHeliosPipeline.prepare_latentsr   latents_meanlatents_stdnum_latent_frames_per_chunkfake_latentsc
                 C   s   |p| j }|d u r&|dj|| jjd}| j|jj|d}|| | }|	d u rg|d | j d }
|	dd|
ddj|| jjd}| j|jj|d}|| | }|d d d d dd d d d d f }	|j||d|	j||dfS )Nr   r   r   r   rg   )
rh   	unsqueezerq   r<   rS   encodelatent_distsamplerG   rv   )rK   r   r   r   r   rS   rR   r   r6   r   
min_frames
fake_videofake_latents_fullr    r    r!   prepare_image_latentsc  s   
 &z$HeliosPipeline.prepare_image_latentsr   c	                 C   sz  |p| j }|j|| jjd}|d u r|jd }	|d | j d }
|	|
 }|dkr@td|
 d|	 d| j d| d	| j d
|
 ||
 }|	| }|d d d d ddd d d d f }| j|jj	|d}|| | }g }t
|D ]5}|||
  }||
 }|d d d d ||d d d d f }| j|jj	|d}|| | }|| qrtj|dd}|j||d|j||dfS )Nr   r   r   r   zVideo must have at least z frames (got z8 frames). Required: (num_latent_frames_per_chunk - 1) * z + 1 = (z - 1) * z + 1 = r   r_   )rh   rq   r<   rS   ru   rG   r   r   r   r   rangeappendrb   rc   )rK   r   r   r   r   rS   rR   r   r6   r   r   
num_chunkstotal_valid_framesstart_framefirst_framefirst_frame_latentlatents_chunksichunk_start	chunk_endvideo_chunkchunk_latentsr    r    r!   prepare_video_latents|  sF   

&&z$HeliosPipeline.prepare_video_latentsc                 C      | j S r   _guidance_scaler   r    r    r!   guidance_scale     zHeliosPipeline.guidance_scalec                 C   s
   | j dkS )N      ?r   r   r    r    r!   r     s   
z*HeliosPipeline.do_classifier_free_guidancec                 C   r   r   )_num_timestepsr   r    r    r!   num_timesteps  r   zHeliosPipeline.num_timestepsc                 C   r   r   )_current_timestepr   r    r    r!   current_timestep  r   zHeliosPipeline.current_timestepc                 C   r   r   )
_interruptr   r    r    r!   	interrupt  r   zHeliosPipeline.interruptc                 C   r   r   )_attention_kwargsr   r    r    r!   attention_kwargs  r   zHeliosPipeline.attention_kwargs   2   g      @npi   g"~j?gHzG?)r   r   r   	   Fnum_inference_stepssigmasr   output_typereturn_dictr   callback_on_step_endr   image_latentsfake_image_latentsadd_noise_to_image_latentsimage_noise_sigma_minimage_noise_sigma_maxvideo_latentsadd_noise_to_video_latentsvideo_noise_sigma_minvideo_noise_sigma_maxhistory_sizeskeep_first_frameis_skip_first_chunkc#           ^      C   s
  t |dd}t|ttfr|j}| |||||||||	 t|d}|| _|| _d| _	d| _
| j}#| jj}$t| jjjd| jjjddd|#| jj}%dt| jjjd| jjjddd|#| jj }&|durst|trsd}'n|durt|trt|}'n|jd }'| j||| j|	||||#d\}}| jj}(||(}|dur||(}|dur| jj|||d	}| j||%|&| tj |#|
||d
	\}}|dur
|r
tj!d|#|
d||  | })|)t"|j|
|#d d|) |  }tj!d|#|
d||  | }*|*t"|j|
|#d d|* |  }|dur(| jj#|||d	}| j$||%|&| tj |#|
|d\}}|dur|rtj!d|#|
d||  | })|)t"|j|
|#d d|) |  }g }+|jd |  },t%|,D ]O}-|-|  }.|.|  }/|dddd|.|/ddddf }0|0jd }1tj!|1|#|
d||  | }2|2dd|1dd}2|2t"|0j|
|#d d|2 |0  }3|+&|3 q[tj'|+dd}| jjj(}4| d | j) d }5td||5 d |5 }6t*|}7d}8d}9|!s|d d |d< tj+|'|4|7|| j, || j, |#tj d}:|durtj'|:ddddddddddf |gdd}:|9d7 }9|durP|:jd };|jd }<|<|;k rG|;|< }=tj'|:ddddd|=ddddf |gdd}:n|}:|9|jd 7 }9|!r{t-dt*dg|| }>|>j.dg|| dd\}?}@}A}B}Ctj'|?|Bgdd}Dnt-dt*g || }>|>j.g || dd\}@}A}D}C|C/d}C|D/d}D|A/d}A|@/d}@| jjj0}E| || j,  || j,  |Ed |Ed  |Ed   }F|du rt12dd|d dd n|}t3|F| j4j5dd| j4j5dd| j4j5dd| j4j5dd}Gt%|6D ]}H|Hdk}I|Hdk}J|!rL|:dddd|7 df j.|dd\}K}L}M|du r@|Ir@tj+|'|4d|Mjd |Mjd f|#|Mjd}Nn|}Ntj'|N|Mgdd}On|:dddd|7 df j.|dd\}K}L}O| j6|'|4|||5tj |#|
dd	}| j4j7||#||Gd | j4j8}Pt|P|| j4j9  }Qt|P| _:| j;|di}Rt<|PD ]\}-}S| j=rq|S| _	|S>|jd }T||(}U|O|(}O|L|(}L|K|(}K| j?d  | j|U|T||C|D|A|@|O|L|K|dd!d }VW d   n	1 sw   Y  | jr#| j?d" | j|U|T||C|D|A|@|O|L|K|dd!d }WW d   n	1 sw   Y  |W||V|W   }V| j4j@|V|S||
dd#d }|dur]i }X|D ]
}HtA |H |X|H< q9|| |-|S|X}Y|YBd$|}|YBd%|}|YBd&|}|-t|Pd ksx|-d |Qkr||-d | j4j9 dkr||RC  tDrtEF  q|!r|Ir|du s|"r|Jr|ddddddddddf }|9|jd 7 }9tj'|:|gdd}:|:dddd|9 df }Z|Zdddd|  df |$|& |% }[| jjG|[dd'd }\|8du r|\}8n	tj'|8|\gdd}8W d   n	1 sw   Y  qd| _	|d(kr8|8Hd}]|]d | j) | j) d }]|8ddddd|]f }8| jjI|8|d)}n|Z}| J  |sD|fS tK|d*S )+a9  
        The call function to the pipeline for generation.

        Args:
            prompt (`str` or `list[str]`, *optional*):
                The prompt or prompts to guide the image generation. If not defined, pass `prompt_embeds` instead.
            negative_prompt (`str` or `list[str]`, *optional*):
                The prompt or prompts to avoid during image generation. If not defined, pass `negative_prompt_embeds`
                instead. Ignored when not using guidance (`guidance_scale` < `1`).
            height (`int`, defaults to `384`):
                The height in pixels of the generated image.
            width (`int`, defaults to `640`):
                The width in pixels of the generated image.
            num_frames (`int`, defaults to `132`):
                The number of frames in the generated video.
            num_inference_steps (`int`, defaults to `50`):
                The number of denoising steps. More denoising steps usually lead to a higher quality image at the
                expense of slower inference.
            guidance_scale (`float`, 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.
            num_videos_per_prompt (`int`, *optional*, defaults to 1):
                The number of images to generate per prompt.
            generator (`torch.Generator` or `list[torch.Generator]`, *optional*):
                A [`torch.Generator`](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 is generated by sampling using the supplied random `generator`.
            prompt_embeds (`torch.Tensor`, *optional*):
                Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
                provided, text embeddings are generated from the `prompt` input argument.
            output_type (`str`, *optional*, defaults to `"np"`):
                The output format of the generated image. Choose between `PIL.Image` or `np.array`.
            return_dict (`bool`, *optional*, defaults to `True`):
                Whether or not to return a [`HeliosPipelineOutput`] 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`, `PipelineCallback`, `MultiPipelineCallbacks`, *optional*):
                A function or a subclass of `PipelineCallback` or `MultiPipelineCallbacks` that is called at the end of
                each denoising step during the inference. 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 `512`):
                The maximum sequence length of the text encoder. If the prompt is longer than this, it will be
                truncated. If the prompt is shorter, it will be padded to this length.

        Examples:

        Returns:
            [`~HeliosPipelineOutput`] or `tuple`:
                If `return_dict` is `True`, [`HeliosPipelineOutput`] is returned, otherwise a `tuple` is returned where
                the first element is a list with the generated images and the second element is a list of `bool`s
                indicating whether the corresponding generated image contains "not-safe-for-work" (nsfw) content.
        T)reverser   NFr   r   )rO   r   r   rP   r7   r8   rQ   rR   )r   r   )r   r   r   rS   rR   r   r6   r   )rR   r   )r   rR   )r   r   r   rS   rR   r   r6   r   r_   rg   r   g+?g        base_image_seq_lenr(   max_image_seq_lenr)   r.   r*   r/   r+   )rS   rR   r   r6   )rR   r   r3   )totalcond)hidden_statestimestepencoder_hidden_statesindices_hidden_statesindices_latents_history_shortindices_latents_history_midindices_latents_history_longlatents_history_shortlatents_history_midlatents_history_longr   r   uncond)r   r   r6   r7   r8   )r   latent)r   )frames)Lsortedri   r   r   tensor_inputsr   maxr   r   r   r   rh   r<   rS   rb   tensorrE   r   rw   z_dimrq   r   rj   r   rk   ru   r   r   r9   rJ   
preprocessr   float32randr   preprocess_videor   r   r   rc   in_channelsrG   ro   zerosrI   arangesplitr   
patch_sizer   linspacer4   r=   getr   set_timesteps	timestepsorderr   progress_bar	enumerater   expandcache_contextsteplocalspopupdateXLA_AVAILABLExm	mark_stepdecodere   postprocess_videomaybe_free_model_hooksr   )^rK   rO   r   r   r   r   r   r   r   rP   r   r6   r7   r8   r   r   r   r   r   rQ   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rR   	vae_dtyper   r   ry   transformer_dtypeimage_noise_sigmafake_image_noise_sigmanoisy_latents_chunksnum_latent_chunksr   r   r   latent_chunkchunk_framesframe_sigmasnoisy_chunkr   window_num_framesnum_latent_chunknum_history_latent_frameshistory_videototal_generated_latent_frameshistory_latentshistory_framesvideo_frameskeep_framesindicesindices_prefixr   r   indices_latents_history_1xr   r   r  r0   r3   r   is_first_chunkis_second_chunkr   r   latents_history_1xlatents_prefixr   r  num_warmup_stepsr  tr   latent_model_input
noise_prednoise_uncondcallback_kwargscallback_outputsreal_history_latentscurrent_latentscurrent_videogenerated_framesr    r    r!   __call__  s  l
&










&



	4



6




(





6&$
Y


zHeliosPipeline.__call__)Nr   rN   NN)NTr   NNrN   NN)NNNNN)r   r   r   r   NNNN)NNNN)/__name__
__module____qualname____doc__model_cpu_offload_seqr   _optional_componentsr   r   r   r   r   rB   rj   r   r   rb   rR   rS   r   rx   Tensorr   r   	Generatorr   r   r   propertyr   r   r   r   r   r   no_gradr   EXAMPLE_DOC_STRINGfloatdictr   r   r   r   r	   r:  __classcell__r    r    rL   r!   r5   l   s   

,
	

W
1	

&	

	

)







	
 !#$%&r5   )r(   r)   r*   r+   )6r   typingr   r   numpyr   regexr$   rb   transformersr   r   	callbacksr   r   image_processorr	   loadersr
   modelsr   r   
schedulersr   utilsr   r   r   r   utils.torch_utilsr   rJ   r   pipeline_utilsr   pipeline_outputr   torch_xla.core.xla_modelcore	xla_modelr  r  
get_loggerr;  loggerr   rE  r"   r&   r'   r   rF  r4   r5   r    r    r    r!   <module>   sR   

