Ë
    T^(h�  ã                   ó¼   — d dl Z d dlZd dlmZ d dlmZ d dlZddlm	Z	 ddlm
Z
mZmZ  e«       rd dlZ G d„ d	e
«      Z	 	 	 	 	 dd
ededee   dedededee   fd„Zy)é    N)Úwraps)ÚOptionalé   )Ú__version__é   )ÚExplicitEnumÚis_torch_availableÚis_torchdynamo_compilingc                   ó   — e Zd ZdZdZdZdZy)ÚActionÚnoneÚnotifyÚnotify_alwaysÚraiseN)Ú__name__Ú
__module__Ú__qualname__ÚNONEÚNOTIFYÚNOTIFY_ALWAYSÚRAISE© ó    ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/utils/deprecation.pyr   r      s   „ Ø€DØ€FØ#€MØ�Er   r   Úold_nameÚversionÚnew_nameÚ warn_if_greater_or_equal_versionÚ!raise_if_greater_or_equal_versionÚraise_if_both_namesÚadditional_messagec                 óÖ   ‡ ‡‡‡‡‡‡
‡— t         j                  j                  |«      }t         j                  j                  t        «      }||k\  Š
‰
rd|› �Šnd|› �Šˆˆ
ˆˆ ˆˆˆˆfd„}	|	S )a[  
    Function or method decorator to notify users about deprecated keyword arguments, replacing them with a new name if specified.
    Note that is decorator is `torch.compile`-safe, i.e. it will not cause graph breaks (but no warning will be displayed if compiling).

    This decorator allows you to:
    - Notify users when a keyword argument is deprecated.
    - Automatically replace deprecated keyword arguments with new ones.
    - Raise an error if deprecated arguments are used, depending on the specified conditions.

    By default, the decorator notifies the user about the deprecated argument while the `transformers.__version__` < specified `version`
    in the decorator. To keep notifications with any version `warn_if_greater_or_equal_version=True` can be set.

    Parameters:
        old_name (`str`):
            Name of the deprecated keyword argument.
        version (`str`):
            The version in which the keyword argument was (or will be) deprecated.
        new_name (`Optional[str]`, *optional*):
            The new name for the deprecated keyword argument. If specified, the deprecated keyword argument will be replaced with this new name.
        warn_if_greater_or_equal_version (`bool`, *optional*, defaults to `False`):
            Whether to show warning if current `transformers` version is greater or equal to the deprecated version.
        raise_if_greater_or_equal_version (`bool`, *optional*, defaults to `False`):
            Whether to raise `ValueError` if current `transformers` version is greater or equal to the deprecated version.
        raise_if_both_names (`bool`, *optional*, defaults to `False`):
            Whether to raise `ValueError` if both deprecated and new keyword arguments are set.
        additional_message (`Optional[str]`, *optional*):
            An additional message to append to the default deprecation message.

    Raises:
        ValueError:
            If raise_if_greater_or_equal_version is True and the current version is greater than or equal to the deprecated version, or if raise_if_both_names is True and both old and new keyword arguments are provided.

    Returns:
        Callable:
            A wrapped function that handles the deprecated keyword arguments according to the specified parameters.

    Example usage with renaming argument:

        ```python
        @deprecate_kwarg("reduce_labels", new_name="do_reduce_labels", version="6.0.0")
        def my_function(do_reduce_labels):
            print(do_reduce_labels)

        my_function(reduce_labels=True)  # Will show a deprecation warning and use do_reduce_labels=True
        ```

    Example usage without renaming argument:

        ```python
        @deprecate_kwarg("max_size", version="6.0.0")
        def my_function(max_size):
            print(max_size)

        my_function(max_size=1333)  # Will show a deprecation warning
        ```

    z"and removed starting from version zand will be removed in version c                 óÈ   •‡ ‡‡— t        j                  ‰ «      }t        |j                  j	                  «       «      }d|v Šd|v Št        ‰ «      ˆˆ ˆˆˆˆˆ	ˆ
ˆˆˆfd„«       }|S )NÚselfÚclsc                  óª  •— ‰j                   }‰	r| d   j                  j                   › d|› �}n‰r| d   j                   › d|› �}t        j                  }d }‰|v rV‰
|v rR‰rt        j                  nt        j
                  }d‰› d‰
› d|› d‰
› d|‰
   › d‰› d|‰   › d	�}|j                  ‰«       n^‰|v r:‰
�8‰
|vr4t        j                  }d
‰› d‰› d|› d‰
› d�	}|j                  ‰«      |‰
<   n ‰|v rt        j                  }d
‰› d‰› d|› d	�}|�	‰�|› d‰› �}‰rK‰r$|t        j                  k7  rt        j                  }n%‰s#|t        j                  k(  rt        j                  }|t        j                  k(  rt        |«      ‚|t        j                  t        j
                  fv r&t        «       st        j                  |t        d¬«        ‰| i |¤ŽS )Nr   ú.zBoth `z` and `z` are set for `z
`. Using `ú=z` and ignoring deprecated `z`.ú`z` is deprecated z for `z`. Use `z
` instead.ú r   )Ú
stacklevel)r   Ú	__class__r   r   r   r   Úpopr   Ú
ValueErrorr
   ÚwarningsÚwarnÚFutureWarning)ÚargsÚkwargsÚ	func_nameÚminimum_actionÚmessager!   ÚfuncÚis_class_methodÚis_greater_or_equal_versionÚis_instance_methodr   r   r    r   Úversion_messager   s        €€€€€€€€€€€r   Úwrapped_funcz6deprecate_kwarg.<locals>.wrapper.<locals>.wrapped_funcx   s7  ø€ ð Ÿ™ˆIÙ!Ø# A™w×0Ñ0×9Ñ9Ð:¸!¸I¸;ÐG‘	Ù Ø# A™w×/Ñ/Ð0°°)°Ð=�	ä#Ÿ[™[ˆNØˆGð ˜6Ñ! h°&Ñ&8Ù1D¤§¢Ì&×J^ÑJ^�Ø" 8 *¨G°H°:¸_ÈYÈKÐWaÐbjÐakÐklÐmsÐt|Ñm}Ðl~ð  Zð  [cð  Zdð  deð  flð  muñ  fvð  ewð  wyð  z�Ø—
‘
˜8Õ$ð ˜VÑ#¨Ð(<ÀÐQWÑAWÜ!'§¡�Ø˜h˜ZÐ'7¸Ð7HÈÈyÈkÐYaÐbjÐakÐkuÐv�Ø#)§:¡:¨hÓ#7��xÒ ð ˜VÑ#Ü!'§¡�Ø˜h˜ZÐ'7¸Ð7HÈÈyÈkÐY[Ð\�àÐ"Ð'9Ð'EØ$˜I QÐ'9Ð&:Ð;�ñ +ñ 5¸Ì6Ï;É;Ò9VÜ%+§\¡\‘Nñ :¸nÔPV×P]ÑP]Ò>]Ü%+§[¡[�Nð ¤§¡Ò-Ü  Ó)Ð)à¤F§M¡M´6×3GÑ3GÐ#HÑHÔQiÔQkä—‘˜g¤}ÀÕCá˜Ð( Ñ(Ð(r   )ÚinspectÚ	signatureÚsetÚ
parametersÚkeysr   )r7   ÚsigÚfunction_named_argsr<   r8   r:   r!   r9   r   r   r    r   r;   r   s   `   @@€€€€€€€€r   Úwrapperz deprecate_kwarg.<locals>.wrapperq   sf   û€ ä×Ñ Ó%ˆÜ! #§.¡.×"5Ñ"5Ó"7Ó8ÐØ#Ð':Ð:ÐØÐ#6Ð6ˆä	ˆt‹÷3	)õ 3	)ó 
ð3	)ðj Ðr   )Ú	packagingr   Úparser   )r   r   r   r   r   r    r!   Údeprecated_versionÚcurrent_versionrD   r9   r;   s   ` `````   @@r   Údeprecate_kwargrI   %   sl   ÿ€ ôF #×*Ñ*×0Ñ0°Ó9ÐÜ×'Ñ'×-Ñ-¬kÓ:€OØ"1Ð5GÑ"GÐá"Ø>¸w¸iÐH‰à;¸G¸9ÐEˆ÷=ó =ð~ €Nr   )NFFFN)r=   r/   Ú	functoolsr   Útypingr   Úpackaging.versionrE   Ú r   r   r	   r
   Útorchr   ÚstrÚboolrI   r   r   r   ú<module>rQ      sž   ðó Û Ý Ý ã å ß HÑ Hñ ÔÛôˆ\ô ð #Ø-2Ø.3Ø %Ø(,ñKØðKàðKð �s‰mðKð '+ð	Kð
 (,ðKð ðKð ! ™ôKr   