o
    + ii  ã                   @  sT   d dl mZ d dlmZ d dlmZ d dlmZ er d dlm	Z	 G dd„ deƒZ
dS )	é    )Úannotations)ÚTYPE_CHECKING)ÚEagerParamBase)Ú	to_tensor)ÚTensorc                      s8   e Zd ZdZ	dd‡ fd	d
„Zd‡ fdd„ZeZ‡  ZS )Ú	Parametera{  
    Parameter is a subclass of Tensor, which is a persistable Tensor
    that can be updated by optimizers during training.

    Args:
        data (Tensor, optional): The initial data for the Parameter.
            If None, an empty Tensor will be created. Default: None.
        requires_grad (bool, optional): Whether this Parameter requires gradient computation.
            If True, the Parameter will accumulate gradients during backward pass.
            Default: True.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> # Create a Parameter from existing Tensor
            >>> weight = paddle.to_tensor([1.0, 2.0, 3.0])
            >>> param = paddle.nn.Parameter(weight)
            >>> print(param)

            >>> # Create a Parameter without initial data
            >>> param = paddle.nn.Parameter()
            >>> print(param)
    NTÚdataúTensor | NoneÚrequires_gradÚboolÚreturnc                   s<   |d u rt g ƒ}tƒ j|j|j|d tƒ  |¡ d| _d S )N)Z	trainableT)r   ÚsuperÚ__init__ÚshapeZdtypeZ	_set_implZ	_is_param)Úselfr   r
   ©Ú	__class__© ú_/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/paddle/nn/parameter.pyr   4   s
   
zParameter.__init__Ústrc                   s
   t ƒ  ¡ S )N)r   Ú__repr__)r   r   r   r   r   =   s   
zParameter.__repr__)NT)r   r	   r
   r   r   r   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__str__Ú__classcell__r   r   r   r   r      s    ÿ	r   N)Ú
__future__r   Útypingr   Zpaddle.base.frameworkr   Zpaddle.tensor.creationr   Zpaddler   r   r   r   r   r   Ú<module>   s   