
    &Vf'                         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
d	S )
    )ops)keras_export)KerasTensor)	InputSpec)Layerzkeras.layers.Permutec                   >     e Zd ZdZ fdZd Zd Zd Z fdZ xZ	S )Permutea  Permutes the dimensions of the input according to a given pattern.

    Useful e.g. connecting RNNs and convnets.

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

    Input shape:
        Arbitrary.

    Output shape:
        Same as the input shape, but with the dimensions re-ordered according
        to the specified pattern.

    Example:

    >>> x = keras.Input(shape=(10, 64))
    >>> y = keras.layers.Permute((2, 1))(x)
    >>> y.shape
    (None, 64, 10)
    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      _/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/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                 |    |d         g}| j         D ]}|                    ||                    t          |          S )Nr   )r   appendr   )r   input_shapeoutput_shapedims       r   compute_output_shapezPermute.compute_output_shape.   sI    #A'9 	2 	2CC 01111\"""r   c                 n    |                      |j                  }t          ||j        |j                  S )N)shapedtypesparse)r"   r$   r   r%   r&   )r   inputsr    s      r   compute_output_speczPermute.compute_output_spec4   s9    00>>fl6=
 
 
 	
r   c                 >    t          j        |d| j        z             S )N)r   )axes)r   	transposer   )r   r'   s     r   callzPermute.call:   s    }V$*:;;;;r   c                 b    d| j         i}t                                                      }i ||S )Nr   )r   r   
get_config)r   configbase_configr   s      r   r.   zPermute.get_config=   s4    $)$gg((**(+(((r   )
__name__
__module____qualname____doc__r   r"   r(   r,   r.   __classcell__)r   s   @r   r	   r	      s         2	= 	= 	= 	= 	=# # #
 
 
< < <) ) ) ) ) ) ) ) )r   r	   N)	keras.srcr   keras.src.api_exportr   %keras.src.backend.common.keras_tensorr   keras.src.layers.input_specr   keras.src.layers.layerr   r	   r   r   r   <module>r;      s          - - - - - - = = = = = = 1 1 1 1 1 1 ( ( ( ( ( ( $%%7) 7) 7) 7) 7)e 7) 7) &%7) 7) 7)r   