
    ~Wh                         d Z ddlZddlmc mZ ddlmZ ddlm	Z	 ddl
mZ  ed           G d de                      ZdS )	zContains the Permute layer.    N)Layer)	InputSpec)keras_exportzkeras.layers.Permutec                   8     e Zd ZdZ fdZd Zd Z fdZ xZS )Permuteaf  Permutes the dimensions of the input according to a given pattern.

    Useful e.g. connecting RNNs and convnets.

    Example:

    ```python
    model = Sequential()
    model.add(Permute((2, 1), input_shape=(10, 64)))
    # now: model.output_shape == (None, 64, 10)
    # note: `None` is the batch dimension
    ```

    Args:
      dims: Tuple of integers. Permutation pattern does not include the
        samples dimension. Indexing starts at 1.
        For instance, `(2, 1)` permutes the first and second dimensions
        of the input.

    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 as the input shape, but with the dimensions re-ordered according
      to the specified pattern.
    c           	      V    t                      j        di | t          |          | _        t	          |          t          t          dt          |          dz                       k    rt          d|           t          t          | j                  dz             | _
        d S )N   zInvalid permutation argument `dims` for Permute Layer. The set of indices in `dims` must be consecutive and start from 1. Received dims=)ndim )super__init__tupledimssortedlistrangelen
ValueErrorr   
input_spec)selfr   kwargs	__class__s      d/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/keras/layers/reshaping/permute.pyr   zPermute.__init__<   s    ""6"""$KK	$<<4aTQ 7 788880)-0 0  
 $TY!);<<<    c                     t          j        |                                          }t          j        |          }t	          | j                  D ]\  }}||         }|||dz   <   t          j        |          S )Nr	   )tfTensorShapeas_listcopy	enumerater   )r   input_shapeoutput_shapeidim
target_dims         r   compute_output_shapezPermute.compute_output_shapeG   st    n[1199;;y--	** 	- 	-FAs$S)J",LQ~l+++r   c                 >    t          j        |d| j        z             S )N)r   )perm)r   	transposer   )r   inputss     r   callzPermute.callO   s    |F	)9::::r   c                     d| j         i}t                                                      }t          t	          |                                          t	          |                                          z             S )Nr   )r   r   
get_configdictr   items)r   configbase_configr   s      r   r-   zPermute.get_configR   s[    $)$gg((**D**,,--V\\^^0D0DDEEEr   )	__name__
__module____qualname____doc__r   r&   r+   r-   __classcell__)r   s   @r   r   r      s         :	= 	= 	= 	= 	=, , ,; ; ;F F F F F F F F Fr   r   )r5   r   tensorflow.compat.v2compatv2r   keras.engine.base_layerr   keras.engine.input_specr    tensorflow.python.util.tf_exportr   r   r   r   r   <module>r=      s    " !  ! ! ! ! ! ! ! ! ! ) ) ) ) ) ) - - - - - - : 9 9 9 9 9 $%%7F 7F 7F 7F 7Fe 7F 7F &%7F 7F 7Fr   