B
    ӻd                 @   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 ddd	g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_utilsZ
functionalsubclass
sequentialc             C   sp   | dkrt  rdgnddg} |dkr.ddg}g }d| krN|tjdg|d7 }d| k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   V/var/www/html/venv/lib/python3.7/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 k	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 )Nr   )r   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k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 )Nr   )r   r   )r   r   r   r   r   _   s    z-KerasModelTypeCombination.parameter_modifiersN)r   r   r   r   r   r   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$   

