o
    ñpi	
  ã                   @  s‚   d dl mZ d dlmZ d dlZd dlmZmZ d dlm	Z	 d dl
mZ d dlmZ er4d dlmZmZ d	gZG d
d	„ d	eƒZdS )é    )Úannotations)ÚTYPE_CHECKINGN)Ú
check_typeÚconvert_dtype)ÚVariable)ÚGamma)Úin_dynamic_mode)ÚTensorÚdtypeÚChi2c                      s<   e Zd ZU dZded< ded< ded< d‡ fd	d
„Z‡  ZS )r   aø  
    Creates a Chi-squared distribution parameterized by shape parameter.
    This is exactly equivalent to Gamma(concentration=0.5*df, rate=0.5), :ref:`api_paddle_distribution_Gamma`.

    Args:
        df (float or Tensor): The degree of freedom of the distribution, which should be non-negative. If the input data type is Tensor, it indicates the batch creation of distributions with multiple different parameters, and the `batch_shape` (refer to the :ref:`api_paddle_distribution_Distribution` base class) is the parameter.

    Example:
        .. code-block:: python

            >>> import paddle
            >>> m = paddle.distribution.Chi2(paddle.to_tensor([1.0]))
            >>> sample = m.sample()
            >>> sample.shape
            [1]

    r	   ÚdfÚrater
   úfloat | TensorÚreturnÚNonec                   sœ   t ƒ st|dtttjjfdƒ |  |¡r|| _t	|j
ƒ| _
n|  |¡\| _t ¡ | _
t | jd¡| _t ƒ rAt | jdk¡sAtdƒ‚tƒ  | jd | j¡ d S )Nr   r   g      à?r   z!The arg of `df` must be positive.)r   r   Úfloatr   ÚpaddleZpirÚValueZ_validate_argsr   r   r
   Z
_to_tensorZget_default_dtypeZ	full_liker   ÚallÚ
ValueErrorÚsuperÚ__init__)Úselfr   ©Ú	__class__© ú_/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/paddle/distribution/chi2.pyr   6   s"   ü

zChi2.__init__)r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   Ú__classcell__r   r   r   r   r      s   
 )Ú
__future__r   Útypingr   r   Zpaddle.base.data_feederr   r   Zpaddle.base.frameworkr   Zpaddle.distribution.gammar   Zpaddle.frameworkr   r	   r
   Ú__all__r   r   r   r   r   Ú<module>   s   