
    6bi	                     |    S r SSKJs  Jr  SSKJr  SSKJr  SSK	J
r
  SSKJr  S r\" S5       " S	 S
\5      5       rg)zSoftmax activation layer.    N)backend)Layer)tf_utils)keras_exportc                 f    U [         R                  :X  a  [         R                  R                  S-  $ g)zLarge negative number as Tensor.

This function is necessary because the standard value for epsilon
in this module (-1e9) cannot be represented using tf.float16

Args:
    tensor_type: a dtype to determine the type.

Returns:
    a large negative number.
g       @g    e)tffloat16min)tensor_types    `/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/layers/activation/softmax.py_large_compatible_negativer      s&     bjj zz~~##    zkeras.layers.Softmaxc                   j   ^  \ rS rSrSrSU 4S jjrS	S jrU 4S jr\R                  S 5       r
SrU =r$ )
Softmax0   a  Softmax activation function.

Example without mask:

>>> inp = np.asarray([[1., 2., 1.]])
>>> layer = tf.keras.layers.Softmax()
>>> layer(inp).numpy()
array([[0.21194157, 0.5761169 , 0.21194157]], dtype=float32)
>>> mask = np.asarray([[True, False, True]], dtype=bool)
>>> layer(inp, mask).numpy()
array([[0.5, 0. , 0.5]], dtype=float32)

Input shape:
    Arbitrary. Use the keyword argument `input_shape`
    (tuple of integers, does not include the samples axis)
    when using this layer as the first layer in a model.

Output shape:
    Same shape as the input.

Args:
    axis: Integer, or list of Integers, axis along which the softmax
        normalization is applied.
Call arguments:
    inputs: The inputs, or logits to the softmax layer.
    mask: A boolean mask of the same shape as `inputs`. The mask
        specifies 1 to keep and 0 to mask. Defaults to `None`.


Returns:
    Softmaxed output with the same shape as `inputs`.
c                 @   > [         TU ]  " S0 UD6  SU l        Xl        g )NT )super__init__supports_maskingaxis)selfr   kwargs	__class__s      r   r   Softmax.__init__S   s     "6" $	r   c           	         Ub=  S[         R                  " X!R                  5      -
  [        UR                  5      -  nX-  n[	        U R
                  [        [        45      (       ap  [        U R
                  5      S:  a6  [         R                  " U[         R                  " XR
                  SS9-
  5      $ [        R                  " XR
                  S   S9$ [        R                  " XR
                  S9$ )Ng      ?   T)r   keepdimsr   )r   )r   castdtyper   
isinstancer   tuplelistlenexpreduce_logsumexpr   softmax)r   inputsmaskadders       r   callSoftmax.callX   s     277466*6<<8E OFdii%//499~!vv))&yy4PQ 
 vIIaLAAvII66r   c                    > SU R                   0n[        TU ]	  5       n[        [	        UR                  5       5      [	        UR                  5       5      -   5      $ )Nr   )r   r   
get_configdictr#   items)r   configbase_configr   s      r   r.   Softmax.get_confign   sG    $))$g(*D**,-V\\^0DDEEr   c                     U$ Nr   )r   input_shapes     r   compute_output_shapeSoftmax.compute_output_shapes   s    r   )r   r   )r5   )__name__
__module____qualname____firstlineno____doc__r   r+   r.   r   shape_type_conversionr7   __static_attributes____classcell__)r   s   @r   r   r   0   s3    B
7,F
 ## $r   r   )r>   tensorflow.compat.v2compatv2r   tf_keras.srcr   tf_keras.src.engine.base_layerr   tf_keras.src.utilsr    tensorflow.python.util.tf_exportr   r   r   r   r   r   <module>rI      sI      " !   0 ' :( $%De D &Dr   