Ë
    (täi/  ã                   ó<   — d Z ddlmZ ddlmZ  e«       rddlZd„ Zy)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«      r1t        | j                  d«      r| j                  j                  | «        ‰| g|¢­i |¤ŽS )NÚ_hf_hookÚpre_forward)Úhasattrr   r	   )ÚselfÚargsÚkwargsÚmethods      €úo/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/diffusers/utils/accelerate_utils.pyÚwrapperz#apply_forward_hook.<locals>.wrapper+   sA   ø€ Ü�4˜Ô$¬°·±ÀÔ)NØ�M‰M×%Ñ% dÔ+Ù�dÐ,˜TÒ, VÑ,Ð,ó    )r   r   ÚparseÚ
accelerateÚ__version__Úbase_version)r   Úaccelerate_versionr   s   `  r   Úapply_forward_hookr      sW   ø€ ô #Ô$ØˆÜ Ÿ™¤z×'=Ñ'=Ó>×KÑKÐÜ‡}�}Ð'Ó(¬7¯=©=¸Ó+BÒBØˆô-ð
 €Nr   )Ú__doc__Ú	packagingr   Úimport_utilsr   r   r   © r   r   Ú<module>r      s"   ðñõ å 1ñ ÔÛór   