o
    2h
                     @   sL   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 deZdS )	    )keras_export)	InputSpec)Layer)argument_validationzkeras.layers.Cropping1Dc                       s>   e Zd ZdZd fdd	Zdd Zdd Z fd	d
Z  ZS )
Cropping1Da  Cropping layer for 1D input (e.g. temporal sequence).

    It crops along the time dimension (axis 1).

    Example:

    >>> input_shape = (2, 3, 2)
    >>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
    >>> x
    [[[ 0  1]
      [ 2  3]
      [ 4  5]]
     [[ 6  7]
      [ 8  9]
      [10 11]]]
    >>> y = keras.layers.Cropping1D(cropping=1)(x)
    >>> y
    [[[2 3]]
     [[8 9]]]

    Args:
        cropping: Int, or tuple of int (length 2), or dictionary.
            - If int: how many units should be trimmed off at the beginning and
              end of the cropping dimension (axis 1).
            - If tuple of 2 ints: how many units should be trimmed off at the
              beginning and end of the cropping dimension
              (`(left_crop, right_crop)`).

    Input shape:
        3D tensor with shape `(batch_size, axis_to_crop, features)`

    Output shape:
        3D tensor with shape `(batch_size, cropped_axis, features)`
       r   c                    s6   t  jdi | tj|dddd| _tdd| _d S )N   croppingT)
allow_zero   )ndim )super__init__r   standardize_tupler
   r   
input_spec)selfr
   kwargs	__class__r   `/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/layers/reshaping/cropping1d.pyr   ,   s
   zCropping1D.__init__c                 C   s^   |d d ur$|d | j d  | j d  }|dkr#td| d| j  nd }|d ||d fS )Nr   r   zh`cropping` parameter of `Cropping1D` layer must be smaller than the input length. Received: input_shape=, cropping=r	   )r
   
ValueError)r   input_shapelengthr   r   r   compute_output_shape3   s   zCropping1D.compute_output_shapec                 C   s   |j d d urt| j|j d krtd|j  d| j | jd dkr4|d d | jd d d d f S |d d | jd | jd  d d f S )Nr   zi`cropping` parameter of `Cropping1D` layer must be smaller than the input length. Received: inputs.shape=r   r   )shapesumr
   r   )r   inputsr   r   r   call@   s    (zCropping1D.callc                    s    d| j i}t  }i ||S )Nr
   )r
   r   
get_config)r   configbase_configr   r   r   r!   O   s   

zCropping1D.get_config)r   )	__name__
__module____qualname____doc__r   r   r    r!   __classcell__r   r   r   r   r      s    #r   N)	keras.src.api_exportr   keras.src.layers.input_specr   keras.src.layers.layerr   keras.src.utilsr   r   r   r   r   r   <module>   s    