o
    }oi                     @  s   d dl mZ d dlZd dlZd dlm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 erJd dlmZ d d	lmZ ed
ZedZedZdZd"ddZd#ddZd$ddZ	d%d&ddZ	d%d'd d!ZdS )(    )annotationsN)Any)TYPE_CHECKING)TypeVar)optuna_warn)ExperimentalWarning)Callable)	ParamSpecFTFPCTz

.. note::
    Added in v{ver} as an experimental feature. The interface may change in newer versions
    without prior notice. See https://github.com/optuna/optuna/releases/tag/v{ver}.
option_namestrreturnNonec                 C  s   t d|  dt d S )NzArgument ``zF`` is an experimental feature. The interface can change in the future.)r   r   )r    r   H/home/ubuntu/.local/lib/python3.10/site-packages/optuna/_experimental.pywarn_experimental_argument    s   
r   versionc                 C  s0   t | trt| ddkrtd|  dd S )N.   z?Invalid version specification. Must follow `x.y.z` format but `z
` is given)
isinstancer   lensplit
ValueError)r   r   r   r   _validate_version(   s
   
r   	docstringc                 C  s   d| v r|  dd S dS )N
 )r   )r   r   r   r   _get_docstring_indent/   s   r    name
str | None.Callable[[Callable[FP, FT]], Callable[FP, FT]]c                      t  d fdd}|S )a  Decorate function as experimental.

    Args:
        version: The first version that supports the target feature.
        name: The name of the feature. Defaults to fully qualified name of
        the function, i.e. `f"{func.__module__}.{func.__qualname__}"`. Optional.
    funcCallable[FP, FT]r   c                   sx   j d u rd_ tjd}tj }j  t|| | _ p+j dj  t	
d fd	d
}|S )Nr   verr   argsr   kwargsr   r
   c                    s*   t j  d dtdd | i |S Nz" is experimental (supported from vz*). The interface can change in the future.   )
stacklevelwarningswarnr   )r)   r*   )_namer%   r   r   r   wrapperK   s   z5experimental_func.<locals>.decorator.<locals>.wrapper)r)   r   r*   r   r   r
   )__doc___EXPERIMENTAL_NOTE_TEMPLATEformatr    striptextwrapindent
__module____qualname__	functoolswraps)r%   noter8   r2   r!   r   )r1   r%   r   	decoratorA   s   


z$experimental_func.<locals>.decoratorN)r%   r&   r   r&   r   r   r!   r?   r   r>   r   experimental_func3   s   rB   Callable[[CT], CT]c                   r$   )zDecorate class as experimental.

    Args:
        version: The first version that supports the target feature.
        name: The name of the feature. Defaults to the class name. Optional.
    clsr   r   c                   s   d fdd}|| S )NrD   r   r   c                   s   t | d t | dt d fd	d
}t| d| | jdu r'd| _tjd}t| j}| j t	
|| | | _| S )zDecorates a class as experimental.

            This decorator is supposed to be applied to the experimental class.
            __init____name__selfr   r)   r*   r   r   c                   sB   t jd urn d dtdd  | g|R i | d S r+   r.   )rG   r)   r*   )_original_init_original_namer!   r   r   r   wrapped_initq   s   zLexperimental_class.<locals>.decorator.<locals>.wrapper.<locals>.wrapped_initNr   r'   )rG   r   r)   r   r*   r   r   r   )getattrr;   r<   setattrr3   r4   r5   r    r6   r7   r8   )rD   rJ   r=   r8   r>   )rH   rI   r   r2   i   s   



z6experimental_class.<locals>.decorator.<locals>.wrapperrD   r   r   r   r   )rD   r2   r>   r   r   r?   h   s   z%experimental_class.<locals>.decoratorNrM   r@   rA   r   r>   r   experimental_class[   s   "rN   )r   r   r   r   )r   r   r   r   )r   r   r   r   )N)r   r   r!   r"   r   r#   )r   r   r!   r"   r   rC   )
__future__r   r;   r7   typingr   r   r   r/   optuna._warningsr   optuna.exceptionsr   collections.abcr   typing_extensionsr	   r
   r   r   r4   r   r   r    rB   rN   r   r   r   r   <module>   s.    


*