
    2Vh	                     `    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)	    )tree)keras_export)Layer)serialization_libzkeras.layers.Pipelinec                   R     e Zd ZdZd fd	Zed        ZddZed        Z	d Z
 xZS )	Pipelinea  Applies a series of layers to an input.

    This class is useful to build a preprocessing pipeline,
    in particular an image data augmentation pipeline.
    Compared to a `Sequential` model, `Pipeline` features
    a few important differences:

    - It's not a `Model`, just a plain layer.
    - When the layers in the pipeline are compatible
        with `tf.data`, the pipeline will also
        remain `tf.data` compatible. That is to say,
        the pipeline will not attempt to convert
        its inputs to backend-native tensors
        when in a tf.data context (unlike a `Sequential`
        model).

    Example:

    ```python
    from keras import layers
    preprocessing_pipeline = layers.Pipeline([
        layers.AutoContrast(),
        layers.RandomZoom(0.2),
        layers.RandomRotation(0.2),
    ])

    # `ds` is a tf.data.Dataset
    preprocessed_ds = ds.map(
        preprocessing_pipeline,
        num_parallel_calls=4,
    )
    ```
    c                 P    t         |   |       || _        d| _        d| _        y )N)nameFT)super__init___pipeline_layers_convert_input_args!_allow_non_tensor_positional_args)selflayersr
   	__class__s      W/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/layers/preprocessing/pipeline.pyr   zPipeline.__init__+   s+    d# &#( 15.    c                     | j                   S N)r   )r   s    r   r   zPipeline.layers1   s    $$$r   c                     | j                   D ]L  }i }|j                  r||d<   |j                  r|||d<    ||fi |}|}d }t        j                  ||      }N S )Nmasktrainingc                     t        | dd       S )N_keras_mask)getattr)kts    r   _get_mask_from_keras_tensorz2Pipeline.call.<locals>._get_mask_from_keras_tensor?   s    r=$77r   )r   _call_has_mask_arg_call_has_training_argr   map_structure)r   inputsr   r   layerkwargsoutputsr   s           r   callzPipeline.call5   s}    ** 	LEF''!%v++0D%-z"F-f-GF8 %%&A7KD	L r   c                 n    |d   D cg c]  }t        j                  |       c}|d<    | di |S c c}w )Nr    )r   deserialize_keras_object)clsconfigxs      r   from_configzPipeline.from_configE   sD     H%
 66q9
x }V}	
s   2c                 ^    t        j                  | j                        | j                  d}|S )N)r   r
   )r   serialize_keras_objectr   r
   )r   r+   s     r   
get_configzPipeline.get_configM   s0    '>>%% II	
 r   r   )TN)__name__
__module____qualname____doc__r   propertyr   r&   classmethodr-   r0   __classcell__)r   s   @r   r   r      s@     D6 % %   r   r   N)		keras.srcr   keras.src.api_exportr   keras.src.layers.layerr   keras.src.savingr   r   r(   r   r   <module>r<      s5     - ( . %&Lu L 'Lr   