
    ij`)                     \    d dl mZ d dl mZ d dlmZ  eddg       G d d             Zd Zy	)
    )backend)tree)keras_exportzkeras.InputSpeczkeras.layers.InputSpecc                   F    e Zd ZdZ	 	 	 	 	 	 	 	 	 ddZd Zd Zed        Zy)	InputSpeca  Specifies the rank, dtype and shape of every input to a layer.

    Layers can expose (if appropriate) an `input_spec` attribute:
    an instance of `InputSpec`, or a nested structure of `InputSpec` instances
    (one per input tensor). These objects enable the layer to run input
    compatibility checks for input structure, input rank, input shape, and
    input dtype for the first argument of `Layer.__call__`.

    A `None` entry in a shape is compatible with any dimension.

    Args:
        dtype: Expected dtype of the input.
        shape: Shape tuple, expected shape of the input
            (may include `None` for dynamic axes).
            Includes the batch size.
        ndim: Integer, expected rank of the input.
        max_ndim: Integer, maximum rank of the input.
        min_ndim: Integer, minimum rank of the input.
        axes: Dictionary mapping integer axes to
            a specific dimension value.
        allow_last_axis_squeeze: If `True`, allow inputs of rank N+1 as long
            as the last axis of the input is 1, as well as inputs of rank N-1
            as long as the last axis of the spec is 1.
        name: Expected key corresponding to this input when passing data as
            a dictionary.
        optional: Boolean, whether the input is optional or not.
            An optional input can accept `None` values.

    Example:

    ```python
    class MyLayer(Layer):
        def __init__(self):
            super().__init__()
            # The layer will accept inputs with
            # shape (*, 28, 28) & (*, 28, 28, 1)
            # and raise an appropriate error message otherwise.
            self.input_spec = InputSpec(
                shape=(None, 28, 28, 1),
                allow_last_axis_squeeze=True)
    ```
    Nc
                    |t        j                  |      nd | _        |+t        j                  |      | _        t        |      | _        n|| _        d | _        || _        || _        || _	        |	| _
        || _        	 |xs i }|D 
ci c]  }
t        |
      ||
    c}
| _        | j                  rv| j                  | j                  ]| j                  r| j                  n| j                  dz
  }t!        | j                        }||kD  rt        dj#                  ||            y y y c c}
w # t        t        f$ r t        d|       w xY w)NzAArgument `axes` must be a dict with integer keys. Received: axes=   z5Axis {} is greater than the maximum allowed value: {})r   standardize_dtypedtypestandardize_shapeshapelenndimmax_ndimmin_ndimnameoptionalallow_last_axis_squeezeintaxes
ValueError	TypeErrormaxformat)selfr   r   r   r   r   r   r   r   r   kmax_dimmax_axiss                p/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/keras/src/layers/input_spec.py__init__zInputSpec.__init__3   sM    160AG%%e,t 	
  2259DJE
DIDIDJ  	 '>$	:2D267QQa7DI 99$))/4==3L$(IItyy4==AEG499~H'! ((.x(A  " 4M9 8I& 	""&) 	s   >
D. D)D. )D. .Ec           	         | j                   rdt        | j                          nd| j                  rdt        | j                         nd| j                  rdt        | j                         nd| j                  rdt        | j                         nd| j
                  rdt        | j
                         nd| j                  rdt        | j                         ndg}dd	j                  d
 |D               dS )Nzdtype= zshape=zndim=z	max_ndim=z	min_ndim=zaxes=z
InputSpec(, c              3   &   K   | ]	  }|s|  y w)N ).0xs     r   	<genexpr>z%InputSpec.__repr__.<locals>.<genexpr>h   s     %;Aa%;s   ))r   strr   r   r   r   r   join)r   specs     r   __repr__zInputSpec.__repr___   s    ,0JJvc$**o&'B,0JJvc$**o&'B*.))uS^$%26--yT]]+,-R26--yT]]+,-R*.))uS^$%
 DII%;%;;<A>>    c                     | j                   | j                  | j                  | j                  | j                  | j
                  | j                  dS )Nr   r   r   r   r   r   r   r0   )r   s    r   
get_configzInputSpec.get_configj   s=    ZZZZIIII
 	
r.   c                      | di |S )Nr%   r%   )clsconfigs     r   from_configzInputSpec.from_configu   s    }V}r.   )	NNNNNNFNF)	__name__
__module____qualname____doc__r    r-   r1   classmethodr5   r%   r.   r   r   r      sI    )Z  %*X	?	
  r.   r   c                    | syt        j                  |       } t        |t              rr| D cg c]  }|j                   }}t        |      rNg }|D ]E  }||vr+t        d| dt        |j                                d|       |j                  ||          G |}t        j                  |      }t        |      t        |       k7  r| D cg c]  }||j                   }}t        |      t        |       k(  rQt        |      rFt        d| dt        |        d| dt        |       d		d
j                  d |D              z   dz         t        d| dt        |        dt        |       d|       t        t        ||             D ]  \  }\  }	}||	|j                  rt        |	d      st        d|	 dt!        |	       d| d      t#        j$                  |	j&                        }
t        |
      }|j(                  L|j*                  s@||j(                  k7  r1t        d| d|j                   d| d|j(                   d| d|
       |j,                  ?|=||j,                  kD  r.t        d| d|j                   d| d|j,                   d| 
      |j.                  B|@||j.                  k  r1t        d| d|j                   d| d|j.                   d| d|
       |j0                  \t#        j2                  |	j0                        }||j0                  k7  r.t        d| d|j                   d| d|j0                   d| 
      |j4                  rU|j4                  j7                         D ]8  \  }}|	|
|   |dhvst        d| d|j                   d| d| d| d |
        |j&                  8|j&                  }|j*                  r|
r|
d!   d"k(  r|
dd! }
|r|d!   d"k(  r|dd! }t        ||
      D ]>  \  }}|	|||k7  st        d| d|j                   d| d#|j&                   d$|
 
        yc c}w c c}w )%a  Checks compatibility between the layer and provided inputs.

    This checks that the tensor(s) `inputs` verify the input assumptions
    of a layer (if any). If not, a clear and actional exception gets raised.

    Args:
        input_spec: An InputSpec instance, list of InputSpec instances, a nested
            structure of InputSpec instances, or None.
        inputs: Input tensor, list of input tensors, or a nested structure of
            input tensors.
        layer_name: String, name of the layer (for error message formatting).

    Raises:
        ValueError: in case of mismatch between
            the provided inputs and the expectations of the layer.
    NzMissing data for input "z*". You passed a data dictionary with keys z. Expected the following keys: zLayer "z
" expects z named input(s) with keys z, but it received z4 input tensors. Pass inputs as a dict, e.g. `layer({r#   c              3   (   K   | ]
  }d | d  yw)'z': ...Nr%   )r&   ns     r   r(   z-assert_input_compatibility.<locals>.<genexpr>   s     >aas&M>s   z})`.z input(s), but it received z! input tensors. Inputs received: r   z*Inputs to a layer should be tensors. Got 'z' (of type z) as input for layer 'z'.zInput z with name 'z' of layer 'z0' is incompatible with the layer: expected ndim=z, found ndim=z. Full shape received: z4' is incompatible with the layer: expected max_ndim=z4' is incompatible with the layer: expected min_ndim=z1' is incompatible with the layer: expected dtype=z, found dtype=z0' is incompatible with the layer: expected axis z of input shape to have value z , but received input with shape r	   z1' is incompatible with the layer: expected shape=z, found shape=)r   flatten
isinstancedictr   allr   listkeysappendr   r+   	enumeratezipr   hasattrtyper   r   r   r   r   r   r   r   r
   r   items)
input_specinputs
layer_namer,   nameslist_inputsr   
spec_namesinput_indexr'   r   r   r   axisvalue
spec_shapespec_dimdims                     r   assert_input_compatibilityrX   z   sF   " j)J&$'12t22u:K 1v%$24& 9B./ 088=w@  ""6$<01 !F\\&!F
6{c*o%,6KD$:JdiiK
Kz?c*o-#j/*ZJ/@ A&&0\1Cv;-   ))>:>>	?
   j\C
O+< =  #F} -  &x)
 	

 #,C
,C"D TYa<9 q'"<QC @ G9$::,bJ 
 ))!''25z99 )E)Etyy  [Mdii[ A"| $%%)YYK}TF C,,174  ==$D4==$8 [Mdii[ A"| $))- 8""&)  ==$D4==$8 [Mdii[ A"| $))- 8""& (,,17	4  ::!--agg6E

" [Mdii[ A"| $&&*jj\ 2##('+  99#yy0 
e$t= * % \$)) E&< ())-.L '!A%J 
 ::!J++U2Y!^!#2JE*R.A"5!+CRJ!$Z!7 #'CO3($[Mdii[ I&&0\ 2559ZZL A%%*G- YTA 3" Ls   QQQN)	keras.srcr   r   keras.src.api_exportr   r   rX   r%   r.   r   <module>r[      s=      -  ":;<p p =pfKr.   