
    BVh1                        d Z 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 ddlm	Z	 ddl
mZ dd	l
mZ dd
lmZ  ej                  ddd      Z ej"                  d      Zd Z edg      d        Z edg      d        Zy)z!Switching v2 features on and off.    )tf2)
monitoring)ops)registry)tensor)tensor_shape)control_flow_v2_toggles)resource_variables_toggle)	tf_exportz/tensorflow/version/v2_behaviorz*whether v2_behavior is enabled or disabledstatusdata_v2_callbacksc                 D    t         j                  | | j                         y )N)_DATA_V2_CALLBACKSregister
__module__)data_v2_funcs    R/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/compat/v2_compat.pyregister_data_v2_callbackr   #   s    lL,C,CD    enable_v2_behavior)v1c                     t         j                  d      j                  d       t        j                          t        j                          t        j                          t        j                          t        j                          t        j                          t        j!                         D ]  } t        j#                  |       } |          y)a[  Enables TensorFlow 2.x behaviors.

  This function can be called at the beginning of the program (before `Tensors`,
  `Graphs` or other structures have been created, and before devices have been
  initialized. It switches all global behaviors that are different between
  TensorFlow 1.x and 2.x to behave as intended for 2.x.

  This function is called in the main TensorFlow `__init__.py` file, user should
  not need to call it, except during complex migrations.

  @compatibility(TF2)
  This function is not necessary if you are using TF2. V2 behavior is enabled by
  default.
  @end_compatibility
  enableTN)_v2_behavior_usage_gaugeget_cellsetr   r   r   enable_eager_executionr   enable_v2_tensorshaper
   enable_resource_variablesr   enable_tensor_equalityr	   enable_control_flow_v2r   listlookup)v2_enabler_name
v2_enablers     r   r   r   '   s    " ##H-11$7 **,$$&557!002+002 o#**?;JLr   disable_v2_behaviorc                     t         j                  d      j                  d       t        j                          t        j                          t        j                          t        j                          t        j                          t        j                          t        j!                         D ]  } t        j#                  |       } |          y)a	  Disables TensorFlow 2.x behaviors.

  This function can be called at the beginning of the program (before `Tensors`,
  `Graphs` or other structures have been created, and before devices have been
  initialized. It switches all global behaviors that are different between
  TensorFlow 1.x and 2.x to behave as intended for 1.x.

  User can call this function to disable 2.x behavior during complex migrations.

  @compatibility(TF2)
  Using this function indicates that your software is not compatible
  with eager execution and `tf.function` in TF2.

  To migrate to TF2, rewrite your code to be compatible with eager execution.
  Please refer to the [migration guide]
  (https://www.tensorflow.org/guide/migrate) for additional resource on the
  topic.
  @end_compatibility
  disableTN)r   r   r   r   r(   r   disable_eager_executionr   disable_v2_tensorshaper
   disable_resource_variablesr   disable_tensor_equalityr	   disable_control_flow_v2r   r"   r#   )v2_disabler_namev2_disablers     r   r&   r&   I   s    * ##I.2248++-%%'668  "113,113 $++,<=KMr   N)__doc__tensorflow.pythonr   tensorflow.python.eagerr   tensorflow.python.frameworkr   r   r   r   tensorflow.python.opsr	   r
    tensorflow.python.util.tf_exportr   	BoolGauger   Registryr   r   r   r&    r   r   <module>r9      s    ( ! . + 0 . 4 9 ; 6 0://%0(<  'X&&':; E #$% &B $%& 'r   