+
    Lj(                         ^ RI Ht ^RIHtHt ^RIHt  ! R R]4      t ! R R4      t ! R R	]4      t	 ! R
 R]4      t
 ! R R]4      t ! R R]4      t ! R R]4      tR# )    )Any)ConfigMixinregister_to_config)CONFIG_NAMEc                      a a ] tR t^t oRt]t]R
V 3R ll4       t]	V3R lR l4       t
V3R lR ltV3R lR ltR	tVtV ;t# )PipelineCallbacka  
Base class for all the official callbacks used in a pipeline. This class provides a structure for implementing
custom callbacks and ensures that all callbacks have a consistent interface.

Please implement the following:
    `tensor_inputs`: This should return a list of tensor inputs specific to your callback. You will only be able to
    include
        variables listed in the `._callback_tensor_inputs` attribute of your pipeline class.
    `callback_fn`: This method defines the core functionality of your callback.
c                   < \         SV `  4        Vf   Ve	   Ve   Ve   \        R4      hVe5   \        V\        4      '       d   RTu;8:  d   R8:  g   M \        R4      hR # R # )NzSEither cutoff_step_ratio or cutoff_step_index should be provided, not both or none.              ?z6cutoff_step_ratio must be a float between 0.0 and 1.0.)super__init__
ValueError
isinstancefloat)selfcutoff_step_ratiocutoff_step_index	__class__s   &&&?/app/.local/lib/python3.14/site-packages/diffusers/callbacks.pyr   PipelineCallback.__init__   sk    %*;*C).?.Krss(,e44SDU=\Y\=\UVV >] )    c                0   < V ^8  d   QhRS[ S[,          /#    returnliststr)format__classdict__s   "r   __annotate__PipelineCallback.__annotate__$   s     i itCy ir   c                2    \        R V P                   24      h)z2You need to set the attribute `tensor_inputs` for NotImplementedErrorr   )r   s   &r   tensor_inputsPipelineCallback.tensor_inputs#   s    !$VW[WeWeVf"ghhr   c                6   < V ^8  d   QhRS[ S[S[3,          /# r   dictr   r   )r   r    s   "r   r!   r"   '   s"     j jtTWY\T\~ jr   c                2    \        R V P                   24      h)z3You need to implement the method `callback_fn` for r$   )r   pipeline
step_index	timestepscallback_kwargss   &&&&&r   callback_fnPipelineCallback.callback_fn'   s    !$WX\XfXfWg"hiir   c                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!   r"   *   s"     Q Q4PSUXPX> Qr   c                &    V P                  WW44      # N)r0   )r   r,   r-   timestepr/   s   &&&&&r   __call__PipelineCallback.__call__*   s    hPPr    )r   N)__name__
__module____qualname____firstlineno____doc__r   config_namer   r   propertyr&   r0   r6   __static_attributes____classdictcell____classcell__)r   r    s   @@r   r   r      sY     	 KW W i ij jQ Q Qr   r   c                   d   a  ] tR t^.t o RtV 3R lR lt]V 3R lR l4       tV 3R lR ltRt	V t
R	# )
MultiPipelineCallbacksz
This class is designed to handle multiple pipeline callbacks. It accepts a list of PipelineCallback objects and
provides a unified interface for calling all of them.
c                0   < V ^8  d   QhRS[ S[,          /# )r   	callbacks)r   r   )r   r    s   "r   r!   #MultiPipelineCallbacks.__annotate__4   s     # #$'7"8 #r   c                    Wn         R # r4   rF   )r   rF   s   &&r   r   MultiPipelineCallbacks.__init__4   s    "r   c                0   < V ^8  d   QhRS[ S[,          /# r   r   )r   r    s   "r   r!   rG   8   s     Z ZtCy Zr   c                l    V P                    UUu. uF  qP                   F  q"NK  	  K  	  upp# u uppi r4   )rF   r&   )r   callbackinputs   &  r   r&   $MultiPipelineCallbacks.tensor_inputs7   s+    &*nnYn(BXBXBXnYYYs   0c                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!   rG   ;   s      4PSUXPX> r   c                >    V P                    F  pV! WW44      pK  	  V# )zb
Calls all the callbacks in order with the given arguments and returns the final callback_kwargs.
rI   )r   r,   r-   r5   r/   rM   s   &&&&& r   r6   MultiPipelineCallbacks.__call__;   s&     H&xXWO ' r   rI   N)r9   r:   r;   r<   r=   r   r?   r&   r6   r@   rA   r    s   @r   rD   rD   .   s4     
# # Z Z r   rD   c                   <   a  ] tR t^Et o RtR.tV 3R lR ltRtV tR# )SDCFGCutoffCallbacka  
Callback function for Stable Diffusion Pipelines. After certain number of steps (set by `cutoff_step_ratio` or
`cutoff_step_index`), this callback will disable the CFG.

Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step.
prompt_embedsc                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!    SDCFGCutoffCallback.__annotate__O   s      dSVX[S[n r   c                "   V P                   P                  pV P                   P                  pVe   TM\        VP                  V,          4      pW'8X  d;   W@P
                  ^ ,          ,          pVRR  pRVn        WV P
                  ^ ,          &   V# Nr
   configr   r   intnum_timestepsr&   _guidance_scale)	r   r,   r-   r5   r/   r   r   cutoff_steprV   s	   &&&&&    r   r0   SDCFGCutoffCallback.callback_fnO   s     KK99 KK99 "3!>CH^H^arHrDs 	 $+,>,>q,ABM)"#.M'*H$5BD..q12r   r8   N	r9   r:   r;   r<   r=   r&   r0   r@   rA   rS   s   @r   rU   rU   E   s      %%M r   rU   c                   >   a  ] tR t^bt o Rt. ROtV 3R lR ltRtV tR# )SDXLCFGCutoffCallbacka*  
Callback function for the base Stable Diffusion XL Pipelines. After certain number of steps (set by
`cutoff_step_ratio` or `cutoff_step_index`), this callback will disable the CFG.

Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step.
c                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!   "SDXLCFGCutoffCallback.__annotate__p   s      dSVX[S[n r   c                   V P                   P                  pV P                   P                  pVe   TM\        VP                  V,          4      pW'8X  d   W@P
                  ^ ,          ,          pVRR  pW@P
                  ^,          ,          p	V	RR  p	W@P
                  ^,          ,          p
V
RR  p
RVn        WV P
                  ^ ,          &   WV P
                  ^,          &   WV P
                  ^,          &   V# rZ   r\   )r   r,   r-   r5   r/   r   r   ra   rV   add_text_embedsadd_time_idss   &&&&&      r   r0   !SDXLCFGCutoffCallback.callback_fnp   s     KK99 KK99 "3!>CH^H^arHrDs 	 $+,>,>q,ABM)"#.M-.@.@.CDO-bc2O*+=+=a+@AL',L'*H$5BD..q125DD..q125AD..q12r   r8   N)rV   ri   rj   rc   rS   s   @r   re   re   b   s     M r   re   c                   >   a  ] tR t^t o Rt. ROtV 3R lR ltRtV tR# )SDXLControlnetCFGCutoffCallbacka0  
Callback function for the Controlnet Stable Diffusion XL Pipelines. After certain number of steps (set by
`cutoff_step_ratio` or `cutoff_step_index`), this callback will disable the CFG.

Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step.
c                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!   ,SDXLControlnetCFGCutoffCallback.__annotate__   s      dSVX[S[n r   c                T   V P                   P                  pV P                   P                  pVe   TM\        VP                  V,          4      pW'8X  d   W@P
                  ^ ,          ,          pVRR  pW@P
                  ^,          ,          p	V	RR  p	W@P
                  ^,          ,          p
V
RR  p
W@P
                  ^,          ,          pVRR  pRVn        WV P
                  ^ ,          &   WV P
                  ^,          &   WV P
                  ^,          &   WV P
                  ^,          &   V# rZ   r\   )r   r,   r-   r5   r/   r   r   ra   rV   ri   rj   images   &&&&&       r   r0   +SDXLControlnetCFGCutoffCallback.callback_fn   s$    KK99 KK99 "3!>CH^H^arHrDs 	 $+,>,>q,ABM)"#.M-.@.@.CDO-bc2O*+=+=a+@AL',L $$6$6q$9:E"#JE'*H$5BD..q125DD..q125AD..q125:D..q12r   r8   N)rV   ri   rj   rq   rc   rS   s   @r   rm   rm      s     M r   rm   c                   :   a  ] tR t^t o Rt. tV 3R lR ltRtV tR# )IPAdapterScaleCutoffCallbackaA  
Callback function for any pipeline that inherits `IPAdapterMixin`. After certain number of steps (set by
`cutoff_step_ratio` or `cutoff_step_index`), this callback will set the IP Adapter scale to `0.0`.

Note: This callback mutates the IP Adapter attention processors by setting the scale to 0.0 after the cutoff step.
c                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!   )IPAdapterScaleCutoffCallback.__annotate__   s      dSVX[S[n r   c                    V P                   P                  pV P                   P                  pVe   TM\        VP                  V,          4      pW'8X  d   VP                  R4       V# )Nr
   )r]   r   r   r^   r_   set_ip_adapter_scale)r   r,   r-   r5   r/   r   r   ra   s   &&&&&   r   r0   (IPAdapterScaleCutoffCallback.callback_fn   sa     KK99 KK99 "3!>CH^H^arHrDs 	 $))#.r   r8   Nrc   rS   s   @r   rt   rt      s      M r   rt   c                   >   a  ] tR t^t o RtRR.tV 3R lR ltRtV tR# )SD3CFGCutoffCallbacka   
Callback function for Stable Diffusion 3 Pipelines. After certain number of steps (set by `cutoff_step_ratio` or
`cutoff_step_index`), this callback will disable the CFG.

Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step.
rV   pooled_prompt_embedsc                6   < V ^8  d   QhRS[ S[S[3,          /# r   r)   )r   r    s   "r   r!   !SD3CFGCutoffCallback.__annotate__   s      dSVX[S[n r   c                   V P                   P                  pV P                   P                  pVe   TM\        VP                  V,          4      pW'8X  dn   W@P
                  ^ ,          ,          pVRR  pW@P
                  ^,          ,          p	V	RR  p	RVn        WV P
                  ^ ,          &   WV P
                  ^,          &   V# rZ   r\   )
r   r,   r-   r5   r/   r   r   ra   rV   r|   s
   &&&&&     r   r0    SD3CFGCutoffCallback.callback_fn   s     KK99 KK99 "3!>CH^H^arHrDs 	 $+,>,>q,ABM)"#.M#23E3Ea3H#I #7$  (+H$5BD..q125ID..q12r   r8   Nrc   rS   s   @r   r{   r{      s!      %&<=M r   r{   N)typingr   configuration_utilsr   r   utilsr   r   rD   rU   re   rm   rt   r{   r8   r   r   <module>r      sj     @ $Q{ $QN .* :', 'T-&6 -`#3 0 +  r   