Ë
    ˆ\;j)  ã                   ó:   — d dl mZ  G d„ dej                  «      Zy)é    )Údistributionc                   ób   ‡ — e Zd ZdZˆ fd„Zed„ «       Zed„ «       Zd
d„Zd„ Z	d„ Z
d„ Zd	„ Zˆ xZS )ÚIndependentaæ  
    Reinterprets some of the batch dimensions of a distribution as event dimensions.

    This is mainly useful for changing the shape of the result of
    :meth:`log_prob`.

    Args:
        base (Distribution): The base distribution.
        reinterpreted_batch_rank (int): The number of batch dimensions to
            reinterpret as event dimensions.

    Examples:

        .. code-block:: python

            >>> import paddle
            >>> from paddle.distribution import independent

            >>> beta = paddle.distribution.Beta(paddle.to_tensor([0.5, 0.5]), paddle.to_tensor([0.5, 0.5]))
            >>> print(beta.batch_shape, beta.event_shape)
            (2,) ()
            >>> print(beta.log_prob(paddle.to_tensor(0.2)))
            Tensor(shape=[2], dtype=float32, place=Place(gpu:0), stop_gradient=True,
                    [-0.22843921, -0.22843921])
            >>> reinterpreted_beta = independent.Independent(beta, 1)
            >>> print(reinterpreted_beta.batch_shape, reinterpreted_beta.event_shape)
            () (2,)
            >>> print(reinterpreted_beta.log_prob(paddle.to_tensor([0.2,  0.2])))
            Tensor(shape=[], dtype=float32, place=Place(gpu:0), stop_gradient=True,
                    -0.45687842)
    c                 óÄ  •— t        |t        j                  «      st        dt	        |«      › �«      ‚d|cxk  rt        |j                  «      k  s&n t        dt        |j                  «      › d|› �«      ‚|| _        || _	        |j                  |j                  z   }t        ‰| �1  |d t        |j                  «      |z
   |t        |j                  «      |z
  d  ¬«       y )Nz1Expected type of 'base' is Distribution, but got r   z)Expected 0 < reinterpreted_batch_rank <= z
, but got )Úbatch_shapeÚevent_shape)Ú
isinstancer   ÚDistributionÚ	TypeErrorÚtypeÚlenr   Ú
ValueErrorÚ_baseÚ_reinterpreted_batch_rankr   ÚsuperÚ__init__)ÚselfÚbaseÚreinterpreted_batch_rankÚshapeÚ	__class__s       €úhG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\paddle/distribution/independent.pyr   zIndependent.__init__3   sí   ø€ Ü˜$¤× 9Ñ 9Ô:ÜØCÄDÈÃJÀ<ÐPóð ð Ð,ÔE´°D×4DÑ4DÓ0EÔEÜØ;¼CÀ×@PÑ@PÓ<QÐ;RÐR\Ð]uÐ\vÐwóð ð ˆŒ
Ø)AˆÔ&à× Ñ  4×#3Ñ#3Ñ3ˆÜ‰ÑØØB”#�d×&Ñ&Ó'Ð*BÑBðð Ü�D×$Ñ$Ó%Ð(@Ñ@ÐBðð	 	õ 	
ó    c                 ó.   — | j                   j                  S ©N)r   Úmean©r   s    r   r   zIndependent.meanI   s   € à�z‰z�‰Ðr   c                 ó.   — | j                   j                  S r   )r   Úvariancer   s    r   r   zIndependent.varianceM   s   € à�z‰z×"Ñ"Ð"r   c                 ó8   — | j                   j                  |«      S r   )r   Úsample)r   r   s     r   r!   zIndependent.sampleQ   s   € Ø�z‰z× Ñ  Ó'Ð'r   c                 ól   — | j                  | j                  j                  |«      | j                  «      S r   )Ú_sum_rightmostr   Úlog_probr   ©r   Úvalues     r   r$   zIndependent.log_probT   s/   € Ø×"Ñ"Ø�J‰J×Ñ Ó&¨×(FÑ(Fó
ð 	
r   c                 ó@   — | j                  |«      j                  «       S r   )r$   Úexpr%   s     r   ÚprobzIndependent.probY   s   € Ø�}‰}˜UÓ#×'Ñ'Ó)Ð)r   c                 ój   — | j                  | j                  j                  «       | j                  «      S r   )r#   r   Úentropyr   r   s    r   r+   zIndependent.entropy\   s-   € Ø×"Ñ"Ø�J‰J×ÑÓ  $×"@Ñ"@ó
ð 	
r   c                 óZ   — |dkD  r%|j                  t        t        | d«      «      «      S |S )Nr   )ÚsumÚlistÚrange)r   r&   Úns      r   r#   zIndependent._sum_rightmosta   s)   € Ø01°A²ˆu�y‰yœœe Q B¨›lÓ+Ó,Ð@¸5Ð@r   )© )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r!   r$   r)   r+   r#   Ú__classcell__)r   s   @r   r   r      sP   ø„ ñô@
ð, ñó ðð ñ#ó ð#ó(ò
ò
*ò
ö
Ar   r   N)Úpaddle.distributionr   r
   r   r1   r   r   Ú<module>r9      s    ðõ -ôPA�,×+Ñ+õ PAr   