
    :|h                     l    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  ed       G d de             Z
y	)
    )ops)keras_export)KerasTensor)Layer)operation_utilszkeras.layers.Reshapec                   D     e Zd ZdZ fdZd Zd Zd Zd Z fdZ	 xZ
S )Reshapea"  Layer that reshapes inputs into the given shape.

    Args:
        target_shape: Target shape. Tuple of integers, does not include the
            samples dimension (batch size).

    Input shape:
        Arbitrary, although all dimensions in the input shape must be
        known/fixed. Use the keyword argument `input_shape` (tuple of integers,
        does not include the samples/batch size axis) when using this layer as
        the first layer in a model.

    Output shape:
        `(batch_size, *target_shape)`

    Example:

    >>> x = keras.Input(shape=(12,))
    >>> y = keras.layers.Reshape((3, 4))(x)
    >>> y.shape
    (None, 3, 4)

    >>> # also supports shape inference using `-1` as dimension
    >>> y = keras.layers.Reshape((-1, 2, 2))(x)
    >>> y.shape
    (None, 3, 2, 2)
    c                 D    t        |   di | t        |      | _        y )N )super__init__tupletarget_shape)selfr   kwargs	__class__s      a/var/www/html/test/engine/venv/lib/python3.12/site-packages/keras/src/layers/reshaping/reshape.pyr   zReshape.__init__&   s     "6"!,/    c                 X    |d   gt        j                  |dd  | j                  d      S )Nr      r   )r   compute_reshape_output_shaper   )r   input_shapes     r   compute_output_shapezReshape.compute_output_shape*   s9    N
99AB!2!2N
 	
r   c                 |    | j                  |j                        }t        ||j                  |j                        S )N)shapedtypesparse)r   r   r   r   r   )r   inputsoutput_shapes      r   compute_output_speczReshape.compute_output_spec2   s2    00>fll6==
 	
r   c                 z    t        j                  |dd  | j                  d      }t        d |D              | _        y )Nr   r   c              3   (   K   | ]
  }|dn|  y w)Nr   ).0ds     r   	<genexpr>z Reshape.build.<locals>.<genexpr><   s      ,
'(!)B",
s   )r   r   r   r   _resolved_target_shape)r   r   sample_output_shapes      r   buildzReshape.build8   sB    -JJOT..
 ', ,
,?,
 '
#r   c                 v    t        j                  |t        j                  |      d   f| j                  z         S )Nr   )r   reshaper   r'   )r   r   s     r   callzReshape.call@   s4    {{SYYv&q)+d.I.II
 	
r   c                 H    d| j                   i}t        | 	         }i ||S )Nr   )r   r   
get_config)r   configbase_configr   s      r   r.   zReshape.get_configE   s0     $"3"34g(*(+(((r   )__name__
__module____qualname____doc__r   r   r    r)   r,   r.   __classcell__)r   s   @r   r	   r	      s+    80




) )r   r	   N)	keras.srcr   keras.src.api_exportr   %keras.src.backend.common.keras_tensorr   keras.src.layers.layerr   keras.src.opsr   r	   r   r   r   <module>r;      s5     - = ( ) $%?)e ?) &?)r   