o
    p’×i/  ã                   @   s6   d Z ddlmZ ddlmZ eƒ rddlZdd„ ZdS )z7
Accelerate utilities: Utilities related to accelerate
é    )Úversioné   )Úis_accelerate_availableNc                    s@   t ƒ sˆ S t tj¡j}t |¡t d¡k rˆ S ‡ fdd„}|S )a  
    Decorator that applies a registered CpuOffload hook to an arbitrary function rather than `forward`. This is useful
    for cases where a PyTorch module provides functions other than `forward` that should trigger a move to the
    appropriate acceleration device. This is the case for `encode` and `decode` in [`AutoencoderKL`].

    This decorator looks inside the internal `_hf_hook` property to find a registered offload hook.

    :param method: The method to decorate. This method should be a method of a PyTorch module.
    z0.17.0c                    s8   t | dƒrt | jdƒr| j | ¡ ˆ | g|¢R i |¤ŽS )NÚ_hf_hookÚpre_forward)Úhasattrr   r   )ÚselfÚargsÚkwargs©Úmethod© ú^/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/diffusers/utils/accelerate_utils.pyÚwrapper+   s   z#apply_forward_hook.<locals>.wrapper)r   r   ÚparseÚ
accelerateÚ__version__Úbase_version)r   Úaccelerate_versionr   r   r   r   Úapply_forward_hook   s   
r   )Ú__doc__Ú	packagingr   Úimport_utilsr   r   r   r   r   r   r   Ú<module>   s   