
    Vpf7                        d dl mZ d dlmZmZ d dlZd dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZmZ d dlZe	 	 dd d            Ze	 	 d!ddd"d            Ze	 	 dd#d            Z	 	 dd#dZdS )$    )annotations)overloadLiteralN)lax)numpy)_reduction_dimsAxis)promote_args_inexact)Array	ArrayLikeFar   axisr	   bArrayLike | Nonekeepdimsboolreturn_signLiteral[False]wherereturnr   c                    d S N r   r   r   r   r   r   s         T/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/ops/special.py	logsumexpr      s    uxux    )r   Literal[True]tuple[Array, Array]c                   d S r   r   r   s         r   r   r   #   s     ~A  ~Ar   Array | tuple[Array, Array]c                    d S r   r   r   s         r   r   r   '   s     BE  BEr   c           
         |:t          d| |          \  }}t          j        |dk    |t          j                   }nt          d|           \  }|}t	          ||          \  }}	t          j        |j        |	||t          j                   }
t          j        t          j	        t          j
        |
          |
t          j        |
d                              }
|r|
nt          j        |
|          }t          j        t          j        ||                    |j                                      }|t          j        ||          }|                    |	||          }t          j        |          }|s$t)          j        |j        t(          j                  st/          |          }t          j        t          j        |          |
                    |j                            }|r||fS |t)          j        |j        t(          j                  sit5          j        d          5  t          j        |dk     t          j        t(          j        |j                  |          }ddd           n# 1 swxY w Y   |S )a@  Log-sum-exp reduction.

  JAX implementation of :func:`scipy.special.logsumexp`.

  .. math::
    \mathrm{logsumexp}(a) = \mathrm{log} \sum_j b \cdot \mathrm{exp}(a_{ij})

  where the :math:`j` indices range over one or more dimensions to be reduced.

  Args:
    a: the input array
    axis: the axis or axes over which to reduce. May be either ``None``, an
      int, or a tuple of ints.
    b: scaling factors for :math:`\mathrm{exp}(a)`. Must be broadcastable to the
      shape of `a`.
    keepdims: If ``True``, the axes that are reduced are left in the output as
      dimensions of size 1.
    return_sign: If ``True``, the output will be a ``(result, sign)`` pair,
      where ``sign`` is the sign of the sums and ``result`` contains the
      logarithms of their absolute values. If ``False`` only ``result`` is
      returned and it will contain NaN values if the sums are negative.
    where: Elements to include in the reduction.

  Returns:
    Either an array ``result`` or a pair of arrays ``(result, sign)``, depending
    on the value of the ``return_sign`` argument.
  Nr   r   )r   r   r   initial)r   r   r   F)dtype)r
   jnpr   infr   maxrealr   stop_gradientselectisfinite	full_likeexpand_dimsexpsubastyper%   mulsumsignnp
issubdtypecomplexfloatingabsaddlogjax
debug_nansarraynan)r   r   r   r   r   r   a_arrb_arrpos_dimsdimsamaxamax_with_dimsexp_asumexpr4   outs                   r   r   r   +   s`   : ]'Q::LE5Ieqj%#'22EE!+q11FEE"5$//.(D	$QTQXPX	Y	Y	Y$		3:cl4&8&8$dTU@V@VWW	X	X$#H44x)H)H.
'#'%!6!6u{!C!CDD
E
E%]GE5!!E99$9??&	&		$ ek23EFF [[FV\!:!:;;# ;]2=B4FGG]			 I IIdQh	"&	 B B BCHHcI I I I I I I I I I I I I I I	*s   )>I33I7:I7)NNFFN)r   r   r   r	   r   r   r   r   r   r   r   r   r   r   )NNF)r   r   r   r	   r   r   r   r   r   r   r   r   r   r   )r   r   r   r	   r   r   r   r   r   r   r   r   r   r!   )
__future__r   typingr   r   r;   r   r   r&   jax._src.numpy.reductionsr   r	   jax._src.numpy.utilr
   jax._src.typingr   r   r5   r   r   r   r   <module>rM      sx   # " " " " " $ $ $ $ $ $ $ $ 



             ; ; ; ; ; ; ; ; 4 4 4 4 4 4 , , , , , , , ,     
EIeiy y y y 
y 
EI$A_cA A A A A 
A 
EI[_E E E E 
E FJ[_6 6 6 6 6 6 6r   