a
    \=ic                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ g dZ	ddd	Z
d
d ZG dd dejZG dd dejZejjd Zejejee e f dZejZejZejZdS )zHThis module customizes `test_combinations` for `tf.keras` related tests.    N)tf2)combinations)test_combinations)testing_utils)Z
functionalsubclass
sequentialc                 C   sp   | du rt  rdgnddg} |du r.ddg}g }d| v rN|tjdg|d7 }d| v rl|tjdgdgd7 }|S )a  Returns the default test combinations for tf.keras tests.

  Note that if tf2 is enabled, then v1 session test will be skipped.

  Args:
    mode: List of modes to run the tests. The valid options are 'graph' and
      'eager'. Default to ['graph', 'eager'] if not specified. If a empty list
      is provide, then the test will run under the context based on tf's
      version, eg graph for v1 and eager for v2.
    run_eagerly: List of `run_eagerly` value to be run with the tests.
      Default to [True, False] if not specified. Note that for `graph` mode,
      run_eagerly value will only be False.

  Returns:
    A list contains all the combinations to be used to generate test cases.
  NeagergraphTF)moderun_eagerly)r   enabledr   combine)r
   r   result r   u/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorflow/python/keras/combinations.pykeras_mode_combinations   s    r   c                   C   s   t jtdS )N)
model_type)r   r   KERAS_MODEL_TYPESr   r   r   r   keras_model_type_combinations8   s    r   c                   @   s    e Zd ZdZdd Zdd ZdS )KerasModeCombinationzfCombination for Keras test mode.

  It by default includes v1_session, v2_eager and v2_tf_function.
  c                 C   s(   | dd }|d ur t|gS g S d S Nr   )popr   Zrun_eagerly_scope)selfkwargsr   r   r   r   context_managersB   s    z%KerasModeCombination.context_managersc                 C   s   t dgS r   r   ZOptionalParameterr   r   r   r   parameter_modifiersJ   s    z(KerasModeCombination.parameter_modifiersN__name__
__module____qualname____doc__r   r   r   r   r   r   r   <   s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )KerasModelTypeCombinationaK  Combination for Keras model types when doing model test.

  It by default includes 'functional', 'subclass', 'sequential'.

  Various methods in `testing_utils` to get models will auto-generate a model
  of the currently active Keras model type. This allows unittests to confirm
  the equivalence between different Keras models.
  c                 C   s(   | dd }|tv r t|gS g S d S Nr   )r   r   r   Zmodel_type_scope)r   r   r   r   r   r   r   X   s    z*KerasModelTypeCombination.context_managersc                 C   s   t dgS r$   r   r   r   r   r   r   _   s    z-KerasModelTypeCombination.parameter_modifiersNr   r   r   r   r   r#   N   s   	r#   r   )NN)r"   	functoolsZtensorflow.pythonr   Ztensorflow.python.frameworkr   r   Ztensorflow.python.kerasr   r   r   r   ZTestCombinationr   r#   generatekeywords	_defaultspartialr   timesZNamedObjectr   r   r   r   <module>   s(   

