
    zj
                        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rd dlmZmZ d	gZ G d
 d	e          ZdS )    )annotations)TYPE_CHECKINGN)
check_typeconvert_dtype)Variable)Gamma)in_dynamic_mode)TensordtypeChi2c                  D     e Zd ZU dZded<   ded<   ded<   d
 fd	Z x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:: pycon

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

    r
   dfrater   float | TensorreturnNonec                d   t                      s.t          |dt          t          t          j        j        fd           |                     |          r!|| _        t          |j
                  | _
        n4|                     |          \  | _        t	          j                    | _
        t	          j        | j        d          | _        t                      r,t	          j        | j        dk              st!          d          t#                                          | j        dz  | j                   d S )Nr   r   g      ?r   z!The arg of `df` must be positive.)r	   r   floatr   paddlepirValue_validate_argsr   r   r   
_to_tensorget_default_dtype	full_liker   all
ValueErrorsuper__init__)selfr   	__class__s     h/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/paddle/distribution/chi2.pyr   zChi2.__init__6   s      	&*"23	   r"" 	4DG&rx00DJJ++ITW133DJ$TWc22	 	F:dgk** F !DEEE3	22222    )r   r   r   r   )__name__
__module____qualname____doc____annotations__r   __classcell__)r!   s   @r"   r   r      sf          $ JJJLLLLLL3 3 3 3 3 3 3 3 3 3r#   )
__future__r   typingr   r   paddle.base.data_feederr   r   paddle.base.frameworkr   paddle.distribution.gammar   paddle.frameworkr	   r
   r   __all__r    r#   r"   <module>r2      s    # " " " " "              = = = = = = = = * * * * * * + + + + + + , , , , , , %$$$$$$$$(.3 .3 .3 .3 .35 .3 .3 .3 .3 .3r#   