
    wi/                     D    d Z ddlmZ ddlmZ  e            rddlZd ZdS )z7
Accelerate utilities: Utilities related to accelerate
    )version   )is_accelerate_availableNc                      t                      s S t          j        t          j                  j        }t          j        |          t          j        d          k     r S  f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                     t          | d          r/t          | j        d          r| j                            |             | g|R i |S )N_hf_hookpre_forward)hasattrr   r	   )selfargskwargsmethods      p/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/diffusers/utils/accelerate_utils.pywrapperz#apply_forward_hook.<locals>.wrapper+   s^    4$$ 	,)N)N 	,M%%d+++vd,T,,,V,,,    )r   r   parse
accelerate__version__base_version)r   accelerate_versionr   s   `  r   apply_forward_hookr      ss     #$$  z'=>>K}'((7=+B+BBB- - - - -
 Nr   )__doc__	packagingr   import_utilsr   r   r    r   r   <module>r      sm           1 1 1 1 1 1      r   