
    g                         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
  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dS )    N)wraps)Optional   )__version__   )ExplicitEnumc                       e Zd ZdZdZdZdZdS )Actionnonenotifynotify_alwaysraiseN)__name__
__module____qualname__NONENOTIFYNOTIFY_ALWAYSRAISE     Z/var/www/html/ai-engine/env/lib/python3.11/site-packages/transformers/utils/deprecation.pyr
   r
      s"        DF#MEEEr   r
   F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                            |          }t           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.

    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                                                  }d|v d|v t                      	
fd            }|S )Nselfclsc                  D   j         }	r| d         j        j          d| }nr| d         j          d| }t          j        }d }|v rX
|v rTrt          j        nt          j        }d d
 d| d
 d|
          d d|          d	}|                               nZ|v r:
8
|vr4t          j        }d
 d d| d
 d	}|                              |
<   n|v rt          j        }d
 d d| d	}|	| d }r=r|t          j        k    rt          j        }ns|t          j        k    rt          j        }|t          j        k    rt          |          |t          j        t          j        fv r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   
ValueError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_funcr   s    I! >#Aw09GGIGG		  >#Aw/==)==	#[NG 6!!h&&8&81D!^&J^ z8  z  zH  z  zY  z  zbj  z  zmst|m}  z  z  [c  z  z  fl  mu  fv  z  z  z

8$$$$ V##(<QWAWAW!'vhvvvvyvvbjvvv#)::h#7#7x   V##!'\h\\\\y\\\"'9'E$;;'9;; + 	1 5 16;9V9V%+\NN : 1nPVP]>]>]%+[N -- )))FM63G#HHHg}CCCC4((((r   )inspect	signatureset
parameterskeysr   )r5   sigfunction_named_argsr:   r6   r8   r   r7   r   r   r   r   r9   r   s   `   @@r   wrapperz deprecate_kwarg.<locals>.wrapperk   s    %%!#."5"5"7"788#'::#66	t2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 2	) 
2	)h r   )	packagingr   parser   )r   r   r   r   r   r   r   deprecated_versioncurrent_versionrB   r7   r9   s   ` `````   @@r   deprecate_kwargrG       s    D #*0099'--k::O"15G"G" FHwHHEGEE< < < < < < < < < < < <| Nr   )NFFFN)r;   r-   	functoolsr   typingr   packaging.versionrC    r   r   r
   strboolrG   r   r   r   <module>rN      s#                                    \    #-2.3 %(,I III smI '+	I
 (,I I !I I I I I Ir   