
    
3j              
          S SK r S SKJr  S SKrS SKJrJrJrJr  SSK	J
r
Jr  SSKJrJr  SSKJr  SSKJr  SS	K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!\RD                  " \#5      r$Sr%S r&SS jr'    SS\(S-  S\)\RT                  -  S-  S\+\(   S-  S\+\,   S-  4S jjr- " S S\5      r.g)    N)Callable)	BertModelBertTokenizerQwen2TokenizerQwen2VLForConditionalGeneration   )MultiPipelineCallbacksPipelineCallback)AutoencoderKLMagvitEasyAnimateTransformer3DModel)DiffusionPipeline)FlowMatchEulerDiscreteScheduler)is_torch_xla_availableloggingreplace_example_docstring)randn_tensor)VideoProcessor   )EasyAnimatePipelineOutputTFa  
    Examples:
        ```python
        >>> import torch
        >>> from diffusers import EasyAnimatePipeline
        >>> from diffusers.utils import export_to_video

        >>> # Models: "alibaba-pai/EasyAnimateV5.1-12b-zh"
        >>> pipe = EasyAnimatePipeline.from_pretrained(
        ...     "alibaba-pai/EasyAnimateV5.1-7b-zh-diffusers", torch_dtype=torch.float16
        ... ).to("cuda")
        >>> prompt = (
        ...     "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. "
        ...     "The panda's fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other "
        ...     "pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, "
        ...     "casting a gentle glow on the scene. The panda's face is expressive, showing concentration and joy as it plays. "
        ...     "The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical "
        ...     "atmosphere of this unique musical performance."
        ... )
        >>> sample_size = (512, 512)
        >>> video = pipe(
        ...     prompt=prompt,
        ...     guidance_scale=6,
        ...     negative_prompt="bad detailed",
        ...     height=sample_size[0],
        ...     width=sample_size[1],
        ...     num_inference_steps=50,
        ... ).frames[0]
        >>> export_to_video(video, "output.mp4", fps=8)
        ```
c                    UnUnU u  pVXV-  nXtU-  :  a  Un[        [        XE-  U-  5      5      n	OUn	[        [        X6-  U-  5      5      n[        [        XH-
  S-  5      5      n
[        [        X9-
  S-  5      5      nX4X-   X-   44$ )Ng       @)intround)src	tgt_width
tgt_heighttwthhwrresize_heightresize_widthcrop_top	crop_lefts               n/home/wildlama/miniconda3/lib/python3.13/site-packages/diffusers/pipelines/easyanimate/pipeline_easyanimate.pyget_resize_crop_region_for_gridr&   Q   s    	B	BDA	AG}5!,-E"&1*-.5",345HE2,345I 8#;Y=U"VVV    c                     UR                  [        [        SUR                  5      5      SS9nU R                  [        [        SU R                  5      5      SS9nXU-  -  nX%-  SU-
  U -  -   n U $ )a  
Rescales `noise_cfg` tensor based on `guidance_rescale` to improve image quality and fix overexposure. Based on
Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are
Flawed](https://huggingface.co/papers/2305.08891).

Args:
    noise_cfg (`torch.Tensor`):
        The predicted noise tensor for the guided diffusion process.
    noise_pred_text (`torch.Tensor`):
        The predicted noise tensor for the text-guided diffusion process.
    guidance_rescale (`float`, *optional*, defaults to 0.0):
        A rescale factor applied to the noise predictions.

Returns:
    noise_cfg (`torch.Tensor`): The rescaled noise prediction tensor.
r   T)dimkeepdim)stdlistrangendim)	noise_cfgnoise_pred_textguidance_rescalestd_textstd_cfgnoise_pred_rescaleds         r%   rescale_noise_cfgr5   d   s{    " ""tE!_5I5I,J'KUY"ZHmmU1inn%= >mMG#''9: 6!>N:NR[9[[Ir'   num_inference_stepsdevice	timestepssigmasc                    Ub  Ub  [        S5      eUb  S[        [        R                  " U R                  5      R
                  R                  5       5      ;   nU(       d  [        SU R                   S35      eU R                  " S
X2S.UD6  U R                  n[        U5      nX14$ Ub  S[        [        R                  " U R                  5      R
                  R                  5       5      ;   nU(       d  [        SU R                   S35      eU R                  " S
XBS.UD6  U R                  n[        U5      nX14$ U R                  " U4S	U0UD6  U R                  nX14$ )a  
Calls the scheduler's `set_timesteps` method and retrieves timesteps from the scheduler after the call. Handles
custom timesteps. Any kwargs will be supplied to `scheduler.set_timesteps`.

Args:
    scheduler (`SchedulerMixin`):
        The scheduler to get timesteps from.
    num_inference_steps (`int`):
        The number of diffusion steps used when generating samples with a pre-trained model. If used, `timesteps`
        must be `None`.
    device (`str` or `torch.device`, *optional*):
        The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
    timesteps (`list[int]`, *optional*):
        Custom timesteps used to override the timestep spacing strategy of the scheduler. If `timesteps` is passed,
        `num_inference_steps` and `sigmas` must be `None`.
    sigmas (`list[float]`, *optional*):
        Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
        `num_inference_steps` and `timesteps` must be `None`.

Returns:
    `tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
    second element is the number of inference steps.
zYOnly one of `timesteps` or `sigmas` can be passed. Please choose one to set custom valuesr8   zThe current scheduler class zx's `set_timesteps` does not support custom timestep schedules. Please check whether you are using the correct scheduler.)r8   r7   r9   zv's `set_timesteps` does not support custom sigmas schedules. Please check whether you are using the correct scheduler.)r9   r7   r7    )

ValueErrorsetinspect	signatureset_timesteps
parameterskeys	__class__r8   len)	schedulerr6   r7   r8   r9   kwargsaccepts_timestepsaccept_sigmass           r%   retrieve_timestepsrI      s}   > !3tuu'3w/@/@AXAX/Y/d/d/i/i/k+ll .y/B/B.C Da b  	M)MfM''	!)n )) 
	 C(9(9):Q:Q(R(](](b(b(d$ee.y/B/B.C D_ `  	GvGG''	!)n )) 	 3MFMfM''	))r'   c            -         ^  \ rS rSrSrSr/ SQrS\S\\	-  S\
\-  S\S	\4
U 4S
 jjr          S8S\\\   -  S\S\S\\\   -  S-  S\R(                  S-  S\R(                  S-  S\R(                  S-  S\R(                  S-  S\R*                  S-  S\R,                  S-  S\4S jjrS r      S9S jr S:S jr\S 5       r\S 5       r\S 5       r\S  5       r\S! 5       r \RB                  " 5       \"" \#5      SS"S#S#S$S%SSS&SSSSSSSS'SSS(/S&4S\\\   -  S)\S-  S*\S-  S+\S-  S,\S-  S-\$S-  S\\\   -  S-  S\S-  S.\$S-  S/\RJ                  \\RJ                     -  S-  S(\R(                  S-  S\R(                  S-  S0\\   S-  S\R(                  S-  S\R(                  S-  S\R(                  S-  S1\S-  S2\S3\&\\/S4   \'-  \(-  S-  S4\\   S5\$4*S6 jj5       5       r)S7r*U =r+$ );EasyAnimatePipeline   a~  
Pipeline for text-to-video generation using EasyAnimate.

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.)

EasyAnimate uses one text encoder [qwen2 vl](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct) in V5.1.

Args:
    vae ([`AutoencoderKLMagvit`]):
        Variational Auto-Encoder (VAE) Model to encode and decode video to and from latent representations.
    text_encoder (`~transformers.Qwen2VLForConditionalGeneration`, `~transformers.BertModel` | None):
        EasyAnimate uses [qwen2 vl](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct) in V5.1.
    tokenizer (`~transformers.Qwen2Tokenizer`, `~transformers.BertTokenizer` | None):
        A `Qwen2Tokenizer` or `BertTokenizer` to tokenize text.
    transformer ([`EasyAnimateTransformer3DModel`]):
        The EasyAnimate model designed by EasyAnimate Team.
    scheduler ([`FlowMatchEulerDiscreteScheduler`]):
        A scheduler to be used in combination with EasyAnimate to denoise the encoded image latents.
ztext_encoder->transformer->vae)latentsprompt_embedsnegative_prompt_embedsvaetext_encoder	tokenizertransformerrE   c                   > [         TU ]  5         U R                  UUUUUS9  [        U SS 5      b   U R                  R
                  R                  OSU l        [        U SS 5      b  U R                  R                  OSU l	        [        U SS 5      b  U R                  R                  OSU l        [        U R                  S9U l        g )N)rP   rQ   rR   rS   rE   rS   TrP         )vae_scale_factor)super__init__register_modulesgetattrrS   configenable_text_attention_maskrP   spatial_compression_ratiovae_spatial_compression_ratiotemporal_compression_ratiovae_temporal_compression_ratior   video_processor)selfrP   rQ   rR   rS   rE   rC   s         r%   rY   EasyAnimatePipeline.__init__   s     	%# 	 	
 t]D1= ##>> 	' 3:$t2L2XDHH..^_ 	* 4;43M3YDHH//_` 	+  .t?a?abr'   r   TNpromptnum_images_per_promptdo_classifier_free_guidancenegative_promptrN   rO   prompt_attention_masknegative_prompt_attention_maskr7   dtypemax_sequence_lengthc           
         U
=(       d    U R                   R                  n
U	=(       d    U R                   R                  n	Ub  [        U[        5      (       a  SnO3Ub!  [        U[
        5      (       a  [        U5      nOUR                  S   nUGc  [        U[        5      (       a  SSUS./S./nOU Vs/ s H  nSSUS./S.PM     nnU Vs/ s H  oR                  R                  U/SSS	9PM      nnU R                  US
USSSSS9nUR                  U R                   R                  5      nUR                  nUR                  nU R                  (       a  U R                  UUSS9R                  S   nO[        S5      eUR!                  US5      nUR                  XS9nUR                  u  nnnUR!                  SUS5      nUR#                  UU-  US5      nUR                  U	S9nU(       Ga
  UGc  Ub   [        U[        5      (       a  SSUS./S./nOU Vs/ s H  nSSUS./S.PM     nnU Vs/ s H  oR                  R                  U/SSS	9PM      nnU R                  US
USSSSS9nUR                  U R                   R                  5      nUR                  nUR                  nU R                  (       a  U R                  UUSS9R                  S   nO[        S5      eUR!                  US5      nU(       aU  UR                  S   nUR                  XS9nUR!                  SUS5      nUR#                  X-  US5      nUR                  U	S9nXVXx4$ s  snf s  snf s  snf s  snf )as  
Encodes the prompt into text encoder hidden states.

Args:
    prompt (`str` or `list[str]`, *optional*):
        prompt to be encoded
    device: (`torch.device`):
        torch device
    dtype (`torch.dtype`):
        torch dtype
    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.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.
    prompt_attention_mask (`torch.Tensor`, *optional*):
        Attention mask for the prompt. Required when `prompt_embeds` is passed directly.
    negative_prompt_attention_mask (`torch.Tensor`, *optional*):
        Attention mask for the negative prompt. Required when `negative_prompt_embeds` is passed directly.
    max_sequence_length (`int`, *optional*): maximum sequence length to use for the prompt.
r   r   usertext)typero   )rolecontentFT)tokenizeadd_generation_prompt
max_lengthrightpt)ro   paddingru   
truncationreturn_attention_maskpadding_sidereturn_tensors)	input_idsattention_maskoutput_hidden_stateszLLM needs attention_mask)rk   r7   r7   )rQ   rk   r7   
isinstancestrr,   rD   shaperR   apply_chat_templatetor}   r~   r]   hidden_statesr<   repeatview)rc   re   rf   rg   rh   rN   rO   ri   rj   r7   rk   rl   
batch_sizemessages_promptmro   text_inputstext_input_idsbs_embedseq_len__negative_prompts                          r%   encode_prompt!EasyAnimatePipeline.encode_prompt   s   Z 0**0034,,33*VS"9"9JJvt$<$<VJ&,,Q/J &#&& !'-3V$D#E $*
 $* !'-3W$E#F $*   nvmuhi22A3^b2cmu   ..$.&*$# ) K &..):):)A)ABK(22N$/$>$>!.. $ 1 1,=Rim !2 !-!$ !!;<<$9$@$@AVXY$Z!%((u(D,22'1%,,Q0EqI%**86K+KWVXY 5 8 8 8 G '+A+I*z/3/O/O !'-3_$M#N -<
 -<( !'-3=M$N#O -<   nvmuhi22A3^b2cmu   ..$.&*$# ) K &..):):)A)ABK(22N-8-G-G*..)-):):,#A)- *; *  -	*$& !!;<<-K-R-RShjk-l*&,2215G%;%>%>U%>%Z"%;%B%B1F[]^%_"%;%@%@Acelnp%q"-K-N-NV\-N-]*6KkkAXs   5M%M"M'7%M,c                 n   S[        [        R                  " U R                  R                  5      R
                  R                  5       5      ;   n0 nU(       a  X$S'   S[        [        R                  " U R                  R                  5      R
                  R                  5       5      ;   nU(       a  XS'   U$ )Neta	generator)r=   r>   r?   rE   steprA   rB   )rc   r   r   accepts_etaextra_step_kwargsaccepts_generators         r%   prepare_extra_step_kwargs-EasyAnimatePipeline.prepare_extra_step_kwargs  s     s7#4#4T^^5H5H#I#T#T#Y#Y#[\\'*e$ (3w/@/@ATAT/U/`/`/e/e/g+hh-6k*  r'   c
           
        ^  US-  S:w  d	  US-  S:w  a  [        SU SU S35      eU	bW  [        U 4S jU	 5       5      (       d=  [        ST R                   SU	 V
s/ s H  oT R                  ;  d  M  U
PM     sn
 35      eUb  Ub  [        S	U S
U S35      eUc  Uc  [        S5      eUbA  [        U[        5      (       d,  [        U[
        5      (       d  [        S[        U5       35      eUb  Uc  [        S5      eUb  Ub  [        SU SU S35      eUb  Uc  [        S5      eUbE  UbA  UR                  UR                  :w  a&  [        SUR                   SUR                   S35      eg g g s  sn
f )N   r   z8`height` and `width` have to be divisible by 16 but are z and .c              3   @   >#    U  H  oTR                   ;   v   M     g 7fN)_callback_tensor_inputs).0krc   s     r%   	<genexpr>3EasyAnimatePipeline.check_inputs.<locals>.<genexpr>  s      F
7Y!---7Ys   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 zEMust provide `prompt_attention_mask` when specifying `prompt_embeds`.z'Cannot forward both `negative_prompt`: z and `negative_prompt_embeds`: zWMust provide `negative_prompt_attention_mask` when specifying `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` )r<   allr   r   r   r,   rp   r   )rc   re   heightwidthrh   rN   rO   ri   rj   "callback_on_step_end_tensor_inputsr   s   `          r%   check_inputs EasyAnimatePipeline.check_inputs  s4    B;!urzQWX^W__dejdkklmnn-9# F
7YF
 C
 C
 DTEaEaDbbn  |^  pH  |^vw  ko  kG  kG  bGpq  |^  pH  oI  J  -";08N}o ^0 0  ^ 5w  FC)@)@TZ\`IaIaQRVW]R^Q_`aa$)>)Fdee&+A+M9/9J K*++]_ 
 "-2P2Xvww$)?)K""&<&B&BB --:-@-@,A B.445Q8  C *L$7 pHs   E01E0c
                    U	b  U	R                  XvS9$ UUUS-
  U R                  -  S-   X@R                  -  XPR                  -  4n
[        U[        5      (       a*  [        U5      U:w  a  [        S[        U5       SU S35      e[        XXvS9n	[        U R                  S5      (       a  XR                  R                  -  n	U	$ )N)r7   rk   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   r7   rk   init_noise_sigma)r   ra   r_   r   r,   rD   r<   r   hasattrrE   r   )rc   r   num_channels_latents
num_framesr   r   rk   r7   r   rM   r   s              r%   prepare_latents#EasyAnimatePipeline.prepare_latents  s     ::V:99  !^ C CCaG888777
 i&&3y>Z+GA#i.AQ R&<'gi 
 u&V4>>#566 ? ??Gr'   c                     U R                   $ r   _guidance_scalerc   s    r%   guidance_scale"EasyAnimatePipeline.guidance_scale  s    ###r'   c                     U R                   $ r   )_guidance_rescaler   s    r%   r1   $EasyAnimatePipeline.guidance_rescale  s    %%%r'   c                      U R                   S:  $ )Nr   r   r   s    r%   rg   /EasyAnimatePipeline.do_classifier_free_guidance   s    ##a''r'   c                     U R                   $ r   )_num_timestepsr   s    r%   num_timesteps!EasyAnimatePipeline.num_timesteps  s    """r'   c                     U R                   $ r   )
_interruptr   s    r%   	interruptEasyAnimatePipeline.interrupt  s    r'   1   i   2   g      @        pilrM   r   r   r   r6   r   r   r   r8   output_typereturn_dictcallback_on_step_endr   r1   c                 &   [        U[        [        45      (       a  UR                  n[	        US-  S-  5      n[	        US-  S-  5      nU R                  UUUUUUUUU5	        X`l        UU l        SU l        Ub  [        U[        5      (       a  SnO3Ub!  [        U[        5      (       a  [        U5      nOUR                  S   nU R                  nU R                  b  U R                  R                  nOU R                   R                  nU R#                  UUUUU R$                  UUUUUS9
u  nnnn[&        (       a  SnOUn[        U R(                  [*        5      (       a  [-        U R(                  UUUSS9u  pO[-        U R(                  UUU5      u  pU R                   R.                  R0                  nU R3                  UU-  UUUUUUU
U5	      nU R5                  X5      nU R$                  (       a/  [6        R8                  " X/5      n[6        R8                  " UU/5      nUR;                  US	9nUR;                  US	9n[        U5      XPR(                  R<                  -  -
  n[        U5      U l        U RA                  US
9 n[C        U5       GH]  u  nnU RD                  (       a  M  U R$                  (       a  [6        R8                  " U/S-  5      OUn [G        U R(                  S5      (       a  U R(                  RI                  U U5      n [6        RJ                  " U/U R                  S   -  US	9R;                  U R                  S9n!U R!                  U U!USS9S   n"U"RM                  5       S   U RN                  R.                  RP                  :w  a  U"RS                  SSS9u  n"n#U R$                  (       a  U"RS                  S5      u  n$n%U$UU%U$-
  -  -   n"U R$                  (       a  US:  a  [U        U"W%US9n"U R(                  RV                  " U"UU40 UDSS0D6S   nUb\  0 n&U H  n'[Y        5       U'   U&U''   M     U" U UUU&5      n(U(R[                  SU5      nU(R[                  SU5      nU(R[                  SU5      nU[        U5      S-
  :X  d)  US-   U:  a0  US-   U R(                  R<                  -  S:X  a  UR]                  5         [&        (       d  GMH  [^        R`                  " 5         GM`     SSS5        US:X  d^  SU RN                  R.                  Rb                  -  U-  nU RN                  Re                  USS9S   n)U Rf                  Ri                  U)US9n)OUn)U Rk                  5         U(       d  U)4$ [m        U)S9$ ! , (       d  f       N= f)a  
Generates images or video using the EasyAnimate pipeline based on the provided prompts.

Examples:
    prompt (`str` or `list[str]`, *optional*):
        Text prompts to guide the image or video generation. If not provided, use `prompt_embeds` instead.
    num_frames (`int`, *optional*):
        Length of the generated video (in frames).
    height (`int`, *optional*):
        Height of the generated image in pixels.
    width (`int`, *optional*):
        Width of the generated image in pixels.
    num_inference_steps (`int`, *optional*, defaults to 50):
        Number of denoising steps during generation. More steps generally yield higher quality images but slow
        down inference.
    guidance_scale (`float`, *optional*, defaults to 5.0):
        Encourages the model to align outputs with prompts. A higher value may decrease image quality.
    negative_prompt (`str` or `list[str]`, *optional*):
        Prompts indicating what to exclude in generation. If not specified, use `negative_prompt_embeds`.
    num_images_per_prompt (`int`, *optional*, defaults to 1):
        Number of images to generate for each prompt.
    eta (`float`, *optional*, defaults to 0.0):
        Applies to DDIM scheduling. Controlled by the eta parameter from the related literature.
    generator (`torch.Generator` or `list[torch.Generator]`, *optional*):
        A generator to ensure reproducibility in image generation.
    latents (`torch.Tensor`, *optional*):
        Predefined latent tensors to condition generation.
    prompt_embeds (`torch.Tensor`, *optional*):
        Text embeddings for the prompts. Overrides prompt string inputs for more flexibility.
    negative_prompt_embeds (`torch.Tensor`, *optional*):
        Embeddings for negative prompts. Overrides string inputs if defined.
    prompt_attention_mask (`torch.Tensor`, *optional*):
        Attention mask for the primary prompt embeddings.
    negative_prompt_attention_mask (`torch.Tensor`, *optional*):
        Attention mask for negative prompt embeddings.
    output_type (`str`, *optional*, defaults to "latent"):
        Format of the generated output, either as a PIL image or as a NumPy array.
    return_dict (`bool`, *optional*, defaults to `True`):
        If `True`, returns a structured output. Otherwise returns a simple tuple.
    callback_on_step_end (`Callable`, *optional*):
        Functions called at the end of each denoising step.
    callback_on_step_end_tensor_inputs (`list[str]`, *optional*):
        Tensor names to be included in callback function calls.
    guidance_rescale (`float`, *optional*, defaults to 0.0):
        Adjusts noise levels based on guidance scale.
    original_size (`tuple[int, int]`, *optional*, defaults to `(1024, 1024)`):
        Original dimensions of the output.
    target_size (`tuple[int, int]`, *optional*):
        Desired output dimensions for calculations.
    crops_coords_top_left (`tuple[int, int]`, *optional*, defaults to `(0, 0)`):
        Coordinates for cropping.

Returns:
    [`~pipelines.stable_diffusion.StableDiffusionPipelineOutput`] or `tuple`:
        If `return_dict` is `True`, [`~pipelines.stable_diffusion.StableDiffusionPipelineOutput`] 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.
r   FNr   r   )
re   r7   rk   rf   rg   rh   rN   rO   ri   rj   cpu)mur   )total   scale_model_input)rk   )encoder_hidden_statesr   )r)   r   )r1   r   rM   rN   rO   latent)r   )videor   )frames)7r   r
   r	   tensor_inputsr   r   r   r   r   r   r,   rD   r   _execution_devicerQ   rk   rS   r   rg   XLA_AVAILABLErE   r   rI   r\   in_channelsr   r   torchcatr   orderr   progress_bar	enumerater   r   r   tensorsizerP   latent_channelschunkr5   r   localspopupdatexm	mark_stepscaling_factordecoderb   postprocess_videomaybe_free_model_hooksr   )*rc   re   r   r   r   r6   r   rh   rf   r   r   rM   rN   r8   rO   ri   rj   r   r   r   r   r1   r   r7   rk   timestep_devicer   r   num_warmup_stepsr   itlatent_model_inputt_expand
noise_predr   noise_pred_uncondr0   callback_kwargsr   callback_outputsr   s*                                             r%   __call__EasyAnimatePipeline.__call__  s   l *-=?U,VWW1E1S1S. flb()Ub[B&' 	"!*.
	
  .!1 *VS"9"9JJvt$<$<VJ&,,Q/J''(%%++E$$**E "7(,(H(H+'#9"7+I  
	
"!* =#O$Odnn&EFF-? 3_iTU.*I* .@ 3_i.*I
  $//66BB&&.. 

 !::9J++!II'=&MNM$)II/MOd.e$f!%(((7 5 8 8 8 G y>,?..BVBV,VV!)n%89\!),1>> BFAaAaUYYy1}%=gn"4>>+>??)-)I)IJ\^_)`& !<<.@.F.Fq.I(IRXY\\,22 ] 
 "--&*7 %	 . 
 
 ??$Q'488??+J+JJ$.$4$4QA$4$>MJ 339C9I9I!9L6%!2^YjGj5k!kJ338H38N!2:aq!rJ ..--j!WmHYmglmnop'3&(O?-3Xa[* @';D!Q'X$.229gFG$4$8$8-$XM-=-A-ABZ\r-s*I**A9I/IqSTuX\XfXfXlXlNlpqNq '') =LLNg - :l h&$((//8887BGHHOOGO?BE((::T_:`EE 	##%8O(66G :9s   IVV
V)r   r   r   r   r]   r_   ra   rb   )
r   TNNNNNNN   )NNNNNNr   ),__name__
__module____qualname____firstlineno____doc__model_cpu_offload_seqr   r   r   r   r   r   r   r   rY   r   r,   r   boolr   Tensorr7   rk   r   r   r   r   propertyr   r1   rg   r   r   no_gradr   EXAMPLE_DOC_STRINGfloat	Generatorr   r
   r	   r   __static_attributes____classcell__)rC   s   @r%   rK   rK      s   * =Tc c 6	Ac "M1	c
 3c 3cB &',026-16:59>B&*$(#&`ld3i`l  #`l &*	`l
 tCy4/`l ||d*`l !&t 3`l  %||d2`l ).t(;`l t#`l {{T!`l !`lF!, #"'++/4n nr4 $ $ & & ( ( # #   ]]_12 #'!# *,'*26,-DH'+-1&*6:59>B"' nr9B"%-x7d3ix7 $Jx7 d
	x7
 Tzx7 !4Zx7 x7 tCy4/x7  #Tzx7 T\x7 ??T%//%::TAx7 $x7 ||d*x7 9t#x7 !&t 3x7   %||d2!x7" ).t(;#x7$ 4Z%x7& 'x7( 'Sz4'78;KKNddgkk)x7* -1I+x7,  -x7 3 x7r'   rK   )r   )NNNN)/r>   typingr   r   transformersr   r   r   r   	callbacksr	   r
   modelsr   r   pipelines.pipeline_utilsr   
schedulersr   utilsr   r   r   utils.torch_utilsr   rb   r   pipeline_outputr   torch_xla.core.xla_modelcore	xla_modelr   r   
get_loggerr   loggerr  r&   r5   r   r   r7   r,   r	  rI   rK   r;   r'   r%   <module>r     s         B H 9 9 O O - - 6 ))MM 
		H	% DW&: '+(,"&!%8*t8* %,,%8* Cy4	8*
 K$8*vL	7+ L	7r'   