
    BVhmw                       d Z ddlZddlZddlZddl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 dej                        Z G d	 d
ej                        Z ed      Z ed      Z G d dej                         Z G d dej$                        Z G d dej(                        Zd Zd Zd Z	 	 	 	 d-dZd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#	 	 	 	 d-d!Z$	 	 	 	 d-d"Z%d# Z&d$ Z'd% Z(d& Z)d' Z*d( Z+d) Z,d* Z-d+ Z.d, Z/y).zBUpgrader for Python scripts from 1.* TensorFlow to 2.0 TensorFlow.    N)all_renames_v2)	ast_edits)module_deprecations_v2)reorders_v2c                       e Zd Zd Zy)UnaliasedTFImportc                 <    t         j                  | _        d| _        y )NzThe tf_upgrade_v2 script detected an unaliased `import tensorflow`. The script can only run when importing with `import tensorflow as tf`.)r   ERROR	log_levellog_messageselfs    \/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/tools/compatibility/tf_upgrade_v2.py__init__zUnaliasedTFImport.__init__#   s    __DNDD    N__name__
__module____qualname__r    r   r   r   r   !   s    Er   r   c                       e Zd Zd Zy)VersionedTFImportc                 H    t         j                  | _        d|z   dz   | _        y )Nz*Not upgrading symbols because `tensorflow.z ` was directly imported as `tf`.)r   INFOr   r   )r   versions     r   r   zVersionedTFImport.__init__,   s"    ^^DNDwN:;Dr   Nr   r   r   r   r   r   *   s    <r   r   z	compat.v1z	compat.v2c                       e Zd Zd Zy)TFAPIImportAnalysisSpecc                 H    i | _         t               t        t        d| _        y )N))
tensorflowN)tensorflow.compat.v1tf)tensorflow.compat.v2r!   )symbols_to_detectr   compat_v1_importcompat_v2_importimports_to_detectr   s    r   r   z TFAPIImportAnalysisSpec.__init__8   s     D/1(8(8Dr   Nr   r   r   r   r   r   6   s    r   r   c                       e Zd ZdZd Zy)CompatV1ImportReplacerzAST Visitor that replaces `import tensorflow.compat.v1 as tf`.

  Converts `import tensorflow.compat.v1 as tf` to `import tensorflow as tf`
  c                     |j                   D ])  }|j                  dk(  s|j                  dk(  s#d|_        + | j                  |       y)zSHandle visiting an import node in the AST.

    Args:
      node: Current Node
    r    r!   r   N)namesnameasnamegeneric_visit)r   nodeimport_aliass      r   visit_Importz#CompatV1ImportReplacer.visit_ImportG   sL     

 )


5
5



%(	)
 	tr   N)r   r   r   __doc__r0   r   r   r   r(   r(   A   s    
r   r(   c                   &    e Zd ZdZddZddZd Zy)TFAPIChangeSpecz3List of maps that describe what changed in the API.c                 F   || _         i dd d ddd d d ddd d dddd id	d
d iddd iddd iddd iddd idd ddddddidddidddidddidddidddidddii dd d!id"d d!id#d$d id%d$d id&d'did(d)d*id+d)d*id,d)d*id-d.d/id0d1d2id3d'did4d'did5d'did6d7d8id9d7d8id:d;d<id=d>d8dd?i d@d>d8dd?dAdBdCdDdEd'didFd'didGd'didHd'didId'didJd7d8idKdLdCidMdNdCidOdNdCidPd'didQd7d8idRdSdTdUdVdSdTdUdWdXdYidZdXdYii d[dd\d]d^dd\d]d_d`didad`didbdd8dcdddd8dcdedd8dcdfdd8dcdgdhdiidjdkd>idldkd>idmdkd>idndidoidpdidoidqdrdsdtdud>dvdwdxdydBdCdzi d{d|dBid}d~d>idd~d>idd>dBddd>dBdddBdCddddidddidddidddidddidddidddidddidddiddddddddi dddiddidoiddd>iddd>iddd>iddd>iddd8dddd8dddd8dddd8dddd8dddd8dddd8dddd8dddd8dddd8dddd8di ddd8dddd8dddd8dddd8dddd8ddd8dddd8dddddidd7d8idd>d dddBd ddd dd>dBdddd dddd idddd dƜddd dddd dd dʜdd dddiddiddiddidќ| _        t        j                  | j                         t        j                  | _        || _        | j
                  r!dt        j                  dg dԢի      i| _        ni | _        i | _	        h d֣| _
        g dעg dآg d٢g dڢg dۢg dڢdܜ| _        t        t        j                        | _        | j                  j!                  | j                         t        j"                  df}t        j"                  df}t        j"                  df}t        j$                  df}t        j"                  df}t        j"                  df}t        j"                  df}	t        j$                  df}
t        j&                  df}t        j"                  df}t        j$                  df}t        j$                  df}t        j$                  df}t        j&                  df}t        j&                  df}t        j&                  df}t        j$                  df}d}t        j&                  d|z   f}t        j$                  d|z   f}t        j&                  d|z   f}t        j&                  d|z   f}t        j&                  d|z   f}t        j&                  d|z   f}t        j$                  df}t        j$                  df}i d|d|d|d|d|d|d|d|d|d |d|d|d|d|d|d|d|i d|d	|d
|d|d|d|d|d|d|d|d|d|d|d|d|d|d|i d|d|d|d|d|d|d|d|d|d|d|d|d |d!|d"|d#|d$|i d%|d&|d'|d(|d)|d*|d|
d+|
d,|
d-|
d.|
d/|d0|d1|d2|d3|d4|i d5|d6|d7|d8|d9|d:|d;|d<|d=|d>|d?|d@|dA|dB|dC|dD|dE|i dF|dG|dH|dI|dJ|dK|dL|dM|dN|dO|dP|dQ|dR|dS|	dT|	dU|	dV|	i dW|	dX|	dY|	dZ|	d[|	d\|	d]|	d^|	d_|	d`|	da|	db|	dc|dd|de|df|dg|i dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|i dy|dz|d{|d||d}|d~|d|d|d|d|d|dt        j$                  dfdt        j&                  dfd|d|d|d||||||||||||||||d| _        t        j                  | j(                         t        j*                  j-                         D ]7  \  }}t        j$                  dj/                  ||      f}|| j(                  |<   9 i ddt        j$                  dfiddt        j$                  dfiddt        j$                  dfiddt        j$                  dfiddt        j"                  dfiddt        j"                  dfiddt        j"                  dfiddt        j"                  dfiddt        j$                  dfidd|iddt        j$                  dfidt        j$                  df|ddǐd|idt        j$                  df|ddd|id#dt        j$                  dfiddt        j$                  dfidt        j$                  dfidt        j$                  dfidt        j$                  dfid| _        t        j                  | j0                         i dt2        dt2        dt4        dt6        dt6        dt6        dt6        dt6        dt6        dt6        d3t8        dt:        dt<        dt<        dt<        dt<        dt>        i dt>        dt@        dtB        dtE        jF                  tH        dtJ        dd«      d}tE        jF                  tH        dtL        dĐdŐ«      dtE        jF                  tH        dtL        dĐdƐ«      dtE        jF                  tH        dtL        dĐdɐ«      dtE        jF                  tH        dtN        dĐd̐«      dytE        jF                  tP        dtS        jT                  dΫ      ϫ      dAtE        jF                  tP        dtS        jT                  dΫ      ϫ      dtE        jF                  tV        dѐҫ      dtX        dtX        dtX        dtX        dtE        jF                  tV        dԐҫ      dtX        tZ        t\        t^        t^        t`        tb        tb        tZ        t\        t^        t^        t`        tE        jF                  tP        dtS        jT                  d֫      ϫ      dל| _2        t        j                  | jd                         tf        jh                  | _5        y (  Ntf.test.assert_equal_graph_def)checkpoint_v2hash_table_shared_nameztf.autograph.to_code)	arg_types
arg_valuesindentationztf.autograph.to_graph)r8   r9   tf.nn.embedding_lookupvalidate_indices&tf.image.sample_distorted_bounding_boxseed2tf.gradientscolocate_gradients_with_opstf.hessiansz
*.minimizez*.compute_gradientstf.condtrue_fnfalse_fn)strictfn1fn2	tf.argmin	dimensionaxis	tf.argmaxz
tf.arg_minz
tf.arg_maxztf.math.argminztf.math.argmaxztf.image.crop_and_resizebox_indbox_indicesztf.extract_image_patchesksizessizesztf.image.extract_image_patchesztf.image.resizealign_cornersztf.image.resize_imagesztf.expand_dimsdimtf.batch_to_space
block_sizeblock_shapeztf.space_to_batchtf.nn.space_to_batchztf.constantverify_shapeverify_shape_is_now_always_truetf.convert_to_tensorpreferred_dtype
dtype_hint'tf.nn.softmax_cross_entropy_with_logitsz*tf.nn.softmax_cross_entropy_with_logits_v2ztf.linalg.l2_normalizetf.linalg.norm	keep_dimskeepdimstf.normztf.load_file_system_librarylibrary_filenamelibrary_locationztf.count_nonzeroinput)input_tensorr]   reduction_indicesztf.math.count_nonzeroztf.nn.erosion2dfilters	dilations)kernelratesztf.math.l2_normalizeztf.math.log_softmaxztf.math.softmaxztf.nn.l2_normalizeztf.nn.log_softmaxtf.nn.moments
tf.nn.pooldilation_ratetf.nn.separable_conv2dratetf.nn.depthwise_conv2dztf.nn.softmaxztf.nn.sufficient_statisticstf.debugging.assert_all_finitexmessage)tmsgztf.verify_tensor_all_finitetf.sparse.addthresh	thresholdtf.sparse_addtf.sparse.concatexpand_nonconcat_dims)
concat_dimexpand_nonconcat_dimtf.sparse_concatztf.sparse.split	split_dimtf.sparse_splittf.sparse.reduce_max)reduction_axesr]   tf.sparse_reduce_maxztf.sparse.reduce_sumztf.sparse_reduce_sumztf.nn.max_pool_with_argmaxTargmaxoutput_dtypetf.nn.max_poolvaluetf.nn.avg_poolztf.nn.avg_pool2dtf.multinomialdtypetf.random.multinomialtf.reverse_sequenceseq_axis
batch_axis)seq_dim	batch_dimz*tf.nn.batch_norm_with_global_normalizationmeanvariance)rr   mvztf.nn.dilation2d)filterrh   ztf.nn.conv3dr   ztf.zeros_liketensorztf.ones_likeztf.nn.conv2d_transpose)r   r   ztf.nn.conv3d_transposetf.nn.convolution)r   rk   ztf.gfile.Existsfilenamepathztf.gfile.Removeztf.gfile.Statztf.gfile.Globpatternztf.gfile.MkDirdirnameztf.gfile.MakeDirsztf.gfile.DeleteRecursivelyztf.gfile.IsDirectoryztf.gfile.ListDirectoryztf.gfile.Copysrcdst)oldpathnewpathztf.gfile.Rename)oldnamenewnameztf.gfile.Walkin_ordertopdownztf.random.stateless_multinomialztf.string_to_numberstring_tensorztf.strings.to_numberztf.string_to_hash_bucketztf.strings.to_hash_buckettf.reduce_all)rd   r]   tf.math.reduce_alltf.reduce_anytf.math.reduce_anytf.reduce_mintf.math.reduce_mintf.reduce_maxtf.math.reduce_maxtf.reduce_sumtf.math.reduce_sumtf.reduce_meantf.math.reduce_meantf.reduce_prodtf.math.reduce_prodtf.reduce_logsumexptf.math.reduce_logsumexptf.reduce_join)r]   rd   tf.strings.reduce_joinz
tf.squeezesqueeze_dimstf.nn.weighted_momentstf.nn.conv1d)r   use_cudnn_on_gputf.nn.conv2d)r   r   tf.nn.conv2d_backprop_inputoutput_shape)r   input_sizesout_backpropr   tf.contrib.summary.audiodata)r   family%tf.contrib.summary.create_file_writerr+   tf.contrib.summary.generictag)r+   r   r   tf.contrib.summary.histogramtf.contrib.summary.imagemax_outputs)r   	bad_color
max_imagesr   targetslabelsbytesinput_bytescheckpoint_dirckpt_dir_or_file)tf.contrib.summary.scalarz(tf.nn.weighted_cross_entropy_with_logitsztf.decode_rawztf.io.decode_rawz"tf.contrib.framework.load_variabler   r"   )ztensorflow.contribztensorflow.flagsr    r"   ztensorflow.google)excluded_prefixes>`   tf.padtf.sizetf.shapetf.tuple	tf.substrtf.nn.crelutf.gather_ndtf.transposetf.nn.in_top_ktf.quantize_v2tf.boolean_masktf.io.decode_csvtf.math.in_top_ktf.parse_exampletf.sparse_matmultf.random.poissontf.strings.lengthtf.strings.substrtf.confusion_matrixtf.io.parse_exampletf.nn.depth_to_spacetf.nn.space_to_depthtf.sparse.segment_sumtf.io.serialize_sparsetf.sparse.segment_meantf.parse_single_exampletf.math.confusion_matrixtf.sparse.segment_sqrt_ntf.io.parse_single_exampletf.io.serialize_many_sparse$tf.data.experimental.TensorStructure)tf.data.experimental.TensorArrayStructure*tf.data.experimental.RaggedTensorStructure*tf.data.experimental.SparseTensorStructure9tf.feature_column.categorical_column_with_vocabulary_filerB   r_   rK   rH   rj   rA   r?   r   r   ri   r   r   r   r   r   rt   rw   tf.while_loopr\   r   r   r   r   r   r   r~   rx   r|   rR   r   r   r   r   r   r   r   r   r   r   rX   rU   r   r   r   rn   r;   rl   r   r   r   tf.nn.fractional_avg_pooltf.nn.fractional_max_poolr   tf.nn.ctc_beam_search_decodertf.nn.embedding_lookup_sparsero   r5   #tf.uniform_unit_scaling_initializer$tf.initializers.uniform_unit_scalingr=   r[   )r+   r   sample_rater   r   step)logdir	max_queueflush_millisfilename_suffixr+   )r+   r   metadatar   r   )r+   r   r   r   )r+   r   r   r   r   r   )r   r   r   r   r   r   zvTo use learning rate decay schedules with TensorFlow 2.0, switch to the schedules in `tf.keras.optimizers.schedules`.
z<function name> has been changed to return None, the data argument has been removed, and arguments have been reordered.
The calls have been converted to compat.v1 for safety (even though  they may already have been correct).z<function name> has been changed to return None, and the data and summarize arguments have been removed.
The calls have been converted to compat.v1 for safety (even though  they may already have been correct).ak  (Manual edit required) `tf.contrib.layers.layer_norm` has been deprecated, and its implementation has been integrated with `tf.keras.layers.LayerNormalization` in TensorFlow 2.0. Note that, the default value of `epsilon` is changed to `1e-3` in the new API from `1e-12`, and this may introduce numerical differences. Please check the new API and use that instead.zInitializers no longer have the dtype argument in the constructor or partition_info argument in the __call__ method.
The calls have been converted to compat.v1 for safety (even though they may already have been correct).ztf.metrics have been replaced with object oriented versions in TF 2.0 and after. The metric function calls have been converted to compat.v1 for backward compatibility. Please update these calls to the TF 2.0 versions.ztf.losses have been replaced with object oriented versions in TF 2.0 and after. The loss function calls have been converted to compat.v1 for backward compatibility. Please update these calls to the TF 2.0 versions.zh`partition_strategy` has been removed from <function name>.  The 'div' strategy will be used by default.zuniform_unit_scaling_initializer has been removed. Please use tf.initializers.variance_scaling instead with distribution=uniform to get equivalent behaviour.a  The TF 1.x summary API cannot be automatically migrated to TF 2.0, so symbols have been converted to tf.compat.v1.summary.* and must be migrated manually. Typical usage will only require changes to the summary writing logic, not to individual calls like scalar(). For examples of the new summary API, see the Effective TF 2.0 migration document or check the TF 2.0 TensorBoard tutorials.aH  tf.contrib.summary.* functions have been migrated best-effort to tf.compat.v2.summary.* equivalents where possible, but the resulting code is not guaranteed to work, so please check carefully. For more information about the new summary API, see the Effective TF 2.0 migration document or check the updated TensorBoard tutorials.z<function name> replacement does not accept a 'family' argument; instead regular name scoping should be used. This call site specifies a family argument that has been removed on conversion, so the emitted tag names may be incorrect without manual editing.a3  tf.contrib.summary.create_file_writer() has been ported to the new tf.compat.v2.summary.create_file_writer(), which no longer re-uses existing event files for the same logdir; instead it always opens a new writer/file. The python writer objects must be re-used explicitly if the reusing behavior is desired.ak  (Manual edit required) tf.contrib.summary.record_summaries_every_n_global_steps(n, step) should be replaced by a call to tf.compat.v2.summary.record_if() with the argument `lambda: tf.math.equal(0, global_step % n)` (or in graph mode, the lambda body can be used directly). If no global step was passed, instead use tf.compat.v1.train.get_or_create_global_step().a  (Manual edit required) tf.contrib.summary.graph() has no direct equivalent in TF 2.0 because manual graph construction has been superseded by use of tf.function. To log tf.function execution graphs to the summary writer, use the new tf.compat.v2.summary.trace_* functions instead.a&  (Manual edit required) tf.contrib.summary.import_event() has no direct equivalent in TF 2.0. For a similar experimental feature, try tf.compat.v2.summary.experimental.write_raw_pb() which also accepts serialized summary protocol buffer input, but for tf.Summary protobufs rather than tf.Events.z(This warning is only applicable if the code saves a tf.Keras model) Keras model.save now saves to the Tensorflow SavedModel format by default, instead of HDF5. To continue saving to HDF5, add the argument save_format='h5' to the save() function.a  If you're using the strategy with a custom training loop, note the following changes in methods: make_dataset_iterator->experimental_distribute_dataset, experimental_make_numpy_iterator->experimental_make_numpy_dataset, extended.call_for_each_replica->run, reduce requires an axis argument, unwrap->experimental_local_results experimental_initialize and experimental_finalize no longer needed aS  (Manual edit required) tf.contrib.distribute.MirroredStrategy has been migrated to tf.distribute.MirroredStrategy. Things to note: Constructor arguments have changed. If you are using MirroredStrategy with Keras training framework, the input provided to `model.fit` will be assumed to have global batch size and split across the replicas. zN(Manual edit may be required) tf.distribute.MirroredStrategy API has changed. zu(Manual edit required) tf.contrib.distribute.OneDeviceStrategy has been migrated to tf.distribute.OneDeviceStrategy. z(Manual edit required) tf.contrib.distribute.TPUStrategy has been migrated to tf.distribute.TPUStrategy. Note the slight changes in constructor. z(Manual edit required) tf.contrib.distribute.CollectiveAllReduceStrategy has been migrated to tf.distribute.experimental.MultiWorkerMirroredStrategy. Note the changes in constructor. a  (Manual edit required) tf.contrib.distribute.ParameterServerStrategy has been migrated to tf.compat.v1.distribute.experimental.ParameterServerStrategy (multi machine) and tf.distribute.experimental.CentralStorageStrategy (one machine). Note the changes in constructors. ztf.keras.experimental.export_saved_model and tf.keras.experimental.load_from_saved_model have been deprecated.Please use model.save(path, save_format='tf') (or alternatively tf.keras.models.save_model), and tf.keras.models.load_model(path) instead.ztf.saved_model.load works differently in 2.0 compared to 1.0. See migration information in the documentation of tf.compat.v1.saved_model.load.
The calls have been converted to compat.v1.z*.saveztf.assert_equalztf.assert_none_equalztf.assert_negativeztf.assert_positiveztf.assert_non_negativeztf.assert_non_positiveztf.assert_nearztf.assert_lessztf.assert_less_equalztf.assert_greaterztf.assert_greater_equalztf.assert_integerztf.assert_typeztf.assert_scalarztf.assert_rankztf.assert_rank_at_leastztf.assert_rank_inztf.contrib.layers.layer_normz'tf.contrib.saved_model.load_keras_modelz'tf.contrib.saved_model.save_keras_modelz"tf.contrib.summary.all_summary_opsztf.contrib.summary.graphztf.contrib.summary.import_eventz8tf.contrib.summary.record_summaries_every_n_global_stepsr   ztf.debugging.assert_equalztf.debugging.assert_greaterz!tf.debugging.assert_greater_equalztf.debugging.assert_integerztf.debugging.assert_lessztf.debugging.assert_less_equalztf.debugging.assert_nearztf.debugging.assert_negativez tf.debugging.assert_non_negativez tf.debugging.assert_non_positiveztf.debugging.assert_none_equalztf.debugging.assert_positiveztf.debugging.assert_typeztf.debugging.assert_scalarztf.debugging.assert_rankz!tf.debugging.assert_rank_at_leastztf.debugging.assert_rank_inztf.train.exponential_decayz!tf.train.piecewise_constant_decayztf.train.polynomial_decayztf.train.natural_exp_decayztf.train.inverse_time_decayztf.train.cosine_decayztf.train.cosine_decay_restartsztf.train.linear_cosine_decayz"tf.train.noisy_linear_cosine_decayr   ztf.nn.nce_lossz"tf.nn.safe_embedding_lookup_sparseztf.nn.sampled_softmax_lossz(tf.keras.experimental.export_saved_modelz+tf.keras.experimental.load_from_saved_modelztf.keras.initializers.Zerosztf.keras.initializers.zerosztf.keras.initializers.Onesztf.keras.initializers.onesztf.keras.initializers.Constantztf.keras.initializers.constantz%tf.keras.initializers.VarianceScalingz tf.keras.initializers.Orthogonalz tf.keras.initializers.orthogonalztf.keras.initializers.Identityztf.keras.initializers.identityz$tf.keras.initializers.glorot_uniformz#tf.keras.initializers.glorot_normalztf.initializers.zerosztf.zeros_initializerztf.initializers.onesztf.ones_initializerztf.initializers.constantztf.constant_initializerztf.initializers.random_uniformztf.random_uniform_initializerztf.initializers.random_normalztf.random_normal_initializerz tf.initializers.truncated_normalztf.truncated_normal_initializerz tf.initializers.variance_scalingztf.variance_scaling_initializerztf.initializers.orthogonalztf.orthogonal_initializerztf.initializers.identityztf.glorot_uniform_initializerztf.initializers.glorot_uniformztf.glorot_normal_initializerztf.initializers.glorot_normalztf.losses.absolute_differenceztf.losses.add_lossztf.losses.compute_weighted_lossztf.losses.cosine_distanceztf.losses.get_lossesz!tf.losses.get_regularization_lossz#tf.losses.get_regularization_lossesztf.losses.get_total_lossztf.losses.hinge_lossztf.losses.huber_lossztf.losses.log_lossz%tf.losses.mean_pairwise_squared_errorztf.losses.mean_squared_errorztf.losses.sigmoid_cross_entropyztf.losses.softmax_cross_entropyz&tf.losses.sparse_softmax_cross_entropyztf.metrics.accuracyztf.metrics.aucz!tf.metrics.average_precision_at_kztf.metrics.false_negativesz(tf.metrics.false_negatives_at_thresholdsztf.metrics.false_positivesz(tf.metrics.false_positives_at_thresholdsztf.metrics.meanztf.metrics.mean_absolute_errorztf.metrics.mean_cosine_distanceztf.metrics.mean_iouz"tf.metrics.mean_per_class_accuracyztf.metrics.mean_relative_errorztf.metrics.mean_squared_errorztf.metrics.mean_tensorztf.metrics.percentage_belowztf.metrics.precisionztf.metrics.precision_at_kz"tf.metrics.precision_at_thresholdsztf.metrics.precision_at_top_kztf.metrics.recallztf.metrics.recall_at_kztf.metrics.recall_at_thresholdsztf.metrics.recall_at_top_kz"tf.metrics.root_mean_squared_errorz%tf.metrics.sensitivity_at_specificityz(tf.metrics.sparse_average_precision_at_kz tf.metrics.sparse_precision_at_kz%tf.metrics.specificity_at_sensitivityztf.metrics.true_negativesz'tf.metrics.true_negatives_at_thresholdsztf.metrics.true_positivesz'tf.metrics.true_positives_at_thresholdsztf.get_variablez<function name> returns ResourceVariables by default in 2.0, which have well-defined semantics and are stricter about shapes. You can disable this behavior by passing use_resource=False, or by calling tf.compat.v1.disable_resource_variables().ztf.pywrap_tensorflowz<function name> cannot be converted automatically. `tf.pywrap_tensorflow` will not be distributed with TensorFlow 2.0, please consider an alternative in public TensorFlow APIs.z&tf.contrib.distribute.MirroredStrategyztf.distribute.MirroredStrategyz'tf.contrib.distribute.OneDeviceStrategyz!tf.contrib.distribute.TPUStrategy)z1tf.contrib.distribute.CollectiveAllReduceStrategyz-tf.contrib.distribute.ParameterServerStrategyztf.summary.FileWriterztf.summary.FileWriterCacheztf.summary.Summaryztf.summary.audioztf.summary.histogramztf.summary.imageztf.summary.mergeztf.summary.merge_allztf.summary.scalarztf.summary.tensor_summaryztf.summary.textztf.saved_model.loadztf.saved_model.loader.loadz(Manual edit required) `{}` has been migrated to `{}` in TensorFlow Addons. The API spec may have changed during the migration. Please see https://github.com/tensorflow/addons for more info.)r      zSuse_cudnn_on_gpu has been removed, behavior is now equivalentto setting it to True.ztf.nn.conv2d_backprop_filter)r      )r@   r  zitf.gradients no longer takes 'colocate_gradients_with_ops' argument, it behaves as if it was set to True.)r@      zhtf.hessians no longer takes 'colocate_gradients_with_ops' argument, it behaves as if it was set to True.)r@   r  zoOptimizer.minimize no longer takes 'colocate_gradients_with_ops' argument, it behaves as if it was set to True.zxOptimizer.compute_gradients no longer takes 'colocate_gradients_with_ops' argument, it behaves as if it was set to True.)rE   r  zLtf.cond no longer takes 'strict' argument, it behaves as if was set to True.r   r  )r+   r  a  tf.contrib.summary.create_file_writer() no longer supports implicit writer re-use based on shared logdirs or resource names; this call site passed a 'name' argument that has been removed. The new tf.compat.v2.summary.create_file_writer() replacement has a 'name' parameter but the semantics are the usual ones to name the op itself and do not control writer re-use; writers must be manually re-used if desired.a  tf.contrib.summary.generic() takes a 'name' argument for the op name that also determines the emitted tag (prefixed by any active name scopes), but tf.compat.v2.summary.write(), which replaces it, separates these into 'tag' and 'name' arguments. The 'name' argument here has been converted to 'tag' to preserve a meaningful tag, but any name scopes will not be reflected in the tag without manual editing.))r+   r   )r   r  )r      ztf.contrib.summary.image no longer takes the 'bad_color' argument; caller must now preprocess if needed. This call site specifies a bad_color argument so it cannot be converted safely.))r   r  r  )rP   r  zalign_corners is not supported by tf.image.resize, the new default transformation is close to what v1 provided. If you require exactly the same transformation as before, use compat.v1.image.resize.ztf.image.resize_bilinear)rP   r  zalign_corners is not supported by tf.image.resize, the new default transformation is close to what v1 provided. If you require exactly the same transformation as before, use compat.v1.image.resize_bilinear.zalign_corners is not supported by tf.image.resize, the new default transformation is close to what v1 provided. If you require exactly the same transformation as before, use compat.v1.image.resize_area.zalign_corners is not supported by tf.image.resize, the new default transformation is close to what v1 provided. If you require exactly the same transformation as before, use compat.v1.image.resize_bicubic.zalign_corners is not supported by tf.image.resize, the new default transformation is close to what v1 provided. If you require exactly the same transformation as before, use compat.v1.image.resize_nearest_neighbor.)tf.image.resize_areatf.image.resize_bicubic tf.image.resize_nearest_neighborz*.make_initializable_iteratorz*.make_one_shot_iteratorztf.nn.dropoutztf.to_bfloat16ztf.to_complex128ztf.to_complex64ztf.to_doubleztf.to_floatztf.to_int32ztf.to_int64ztf.image.extract_glimpser  r  r	  r   r   ztf.name_scopeztf.strings.splitz	tf.devicedevice_nameFztf.device no longer takes functions as an argument. We could not determine that the argument value is a string, so the call was converted to compat.v1.)arg_namearg_ok_predicateremove_if_okrq   optimizeTztf.zeros_like no longer takes an optimize argument, and behaves as if optimize=True. This call site specifies something other than optimize=True, so it was converted to compat.v1.ztf.ones_like no longer takes an optimize argument, and behaves as if optimize=True. This call site specifies something other than optimize=True, so it was converted to compat.v1.r   return_same_structureztf.while_loop no longer takes 'return_same_structure' argument and behaves as if return_same_structure=True. This call site specifies something other than return_same_structure=True, so it was converted to compat.v1.r   merge_repeatedztf.nn.ctc_beam_search_decoder no longer takes the 'merge_repeated' argument and behaves as if merge_repeated=False. This call site specifies something other than merge_repeated=False, so it was converted to compat.v1.data_formatNHWC)r  arg_value_astz*tf.contrib.summary.always_record_summariesTrue)condz)tf.contrib.summary.never_record_summariesFalsesave_formath5)z tf.contrib.layers.l1_regularizerz tf.contrib.layers.l2_regularizerz$tf.contrib.layers.xavier_initializerz+tf.contrib.layers.xavier_initializer_conv2dz.tf.contrib.layers.variance_scaling_initializerr   r   zslim.l1_regularizerzslim.l2_regularizerzslim.xavier_initializerzslim.xavier_initializer_conv2dz!slim.variance_scaling_initializerztf.keras.models.save_model)6upgrade_compat_v1_importfunction_keyword_renamesr   !add_contrib_direct_import_supportsymbol_renamesimport_renamer   ImportRenameimport_renameschange_to_functionreordered_function_namesmanual_function_reordersdictr   reordersfunction_reordersupdater   WARNINGr
   function_warningsaddons_symbol_mappingsitemsformatfunction_arg_warnings_iterator_transformer_dropout_transformer_cast_transformer._softmax_cross_entropy_with_logits_transformer_extract_glimpse_transformer_image_resize_transformer_pool_seed_transformer_name_scope_transformer_string_split_rtype_transformer	functoolspartial _rename_if_arg_found_transformer_is_ast_str_is_ast_true_is_ast_false_add_argument_transformerastStr'_add_summary_recording_cond_transformer_add_summary_step_transformer*_contrib_layers_l1_regularizer_transformer*_contrib_layers_l2_regularizer_transformer._contrib_layers_xavier_initializer_transformer8_contrib_layers_variance_scaling_initializer_transformer,_add_uniform_scaling_initializer_transformerfunction_transformersr   MODULE_DEPRECATIONSmodule_deprecations) r   r  r  decay_function_commentassert_return_type_commentassert_rank_comment!contrib_layers_layer_norm_commentinitializers_no_dtype_commentmetrics_commentlosses_comment$deprecate_partition_strategy_comment(uniform_unit_scaling_initializer_commentsummary_api_commentcontrib_summary_comment"contrib_summary_family_arg_comment"contrib_create_file_writer_comment&contrib_summary_record_every_n_commentcontrib_summary_graph_comment$contrib_summary_import_event_comment!keras_default_save_format_commentdistribute_strategy_api_changes!contrib_mirrored_strategy_warningcore_mirrored_strategy_warning#contrib_one_device_strategy_warningcontrib_tpu_strategy_warning#contrib_collective_strategy_warningcontrib_ps_strategy_warning!keras_experimental_export_commentsaved_model_load_warningsymbolreplacementwarnings                                    r   r   zTFAPIChangeSpec.__init__X   s   $<D!t%
 	)!&*+
t% 	!
t% 	 "
t%$ 	!#
%t%* 	1T3
+t%0 	)4
1t%6 	)4
7t%< 	)4
=t%B 	)4 
Ct%H 	
It%R 	
St%X 	
Yt%^ 	
_t%d 	
et%j 	
kt%p 	
qt%v 	#}%
wt%| 	#g%
}t%B 	)g+
Ct%H 	T
It%N 	!T#
Ot%T 	6
Ut%Z 	-
[t%` 	-
at%f 	-!
gt%l 	=
mt%r 	|!
st%x 	264
yt%~ 	567
t%D 	!6#
Et%J 	
Kt%P 	
Qt%V 	& 2(
Wt%\ 	##!'
]t%f 	 ##!'"
gt%p 	 
qt%x 	6!
yt%~ 	6 
t%D 	6
Et%J 	6
Kt%P 	6
Qt%V 	
Wt%\ 	[
]t%b 	!K#
ct%h 	!K#
it%n 	6
ot%t 	&(
ut%z 	)+
{t%B 	&(
Ct%J 	k
Kt%P 	k
Qt%V 	 $;
Wt%^ 	 $;
_t%f 	
gt%l 	
mt%r 	$#!
st%z 	$#!
{t%B 	$#!
Ct%J 	$#!
Kt%R 	%~'
St%X 	W
Yt%^ 	W
_t%d 	W
et%j 	G
kt%p 	 G"
qt%v 	!% 
wt%~ 	57
t%H 	 
It%P 	i
Qt%V 	g
Wt%\ 	g
]t%b 	!#
ct%j 	!#
kt%r 	(
st%z 	
{t%@ 	
At%F 	
Gt%L 		
Mt%R 	v
St%X 	v
Yt%^ 	%v'
_t%d 	v!
et%j 	!v#
kt%p 	
qt%x 	
yt%@	 		
A	t%F	 	*G,
G	t%L	 	W 
M	t%R	 	W!
S	t%X	 	#W%
Y	t%^	 	$W&
_	t%d	 	!'#
e	t%l	 	!'#
m	t%t	 	!'#
u	t%|	 	!'#
}	t%D
 	!'#
E
t%L
 	!'#
M
t%T
 	!'#
U
t%\
 	!'#
]
t%d
 	!'#
e
t%l
 	!'#
m
t%t
 	!'#
u
t%|
 	!'# 
}
t%D 	!'#
Et%L 	!'# 
Mt%T 	!'# 
Ut%\ 	#!'#%
]t%d 	#!'
et%l 	!#!'#
mt%t 	F
ut%z 	!#
{t%@ 	 $
At%H 	 $
It%P 	& $)#	(
Qt%\ 	#%
]t%d 	0D2
et%j 	%'
kt%t 	')
ut%| 	#'	%
}t%J &

 x5
 ]
 ]
 0/
ct%D!j 44%%'
 )77D&D
$$(%
d d !Df%D!X%N2N'<)0%K&0%D!" "+"6"67D!!$"?"?@ 		> 		0" 		0 		9)% 	 C%D! 		 O 		 N 		7,8( 		'0(, 		HI 		IJ 		=*>& 		.*/& 		N.O* 		%! 		+,,( 		<)=%	N $ 		 
 #B	B)C% 		5	6&7" 		='	(+)' 		*,K	L$M  		# &E		E+F' 	 7 	((#) 		4)5% 		8 9L-L 	&	L
 	&L 	&L 	&L 	!&L 	!&L 	&!L" 	&%L& 	&)L* 	&-L. 	"&1L2 	&5L6 	&9L: 	&=L> 	ALB 	"ELF 	ILJ 	'-MLN 	2-QLR 	2-ULV 	-#YLZ 	##]L^ 	0.aLb 	%#eLf 	#)iLj 	'#mLn 	*0qLr 	##uLv 	C2yLz 	$#}L~ 	$&ALB 	&&ELF 	,&ILJ 	&&MLN 	#&QLR 	)&ULV 	#&YLZ 	'&]L^ 	+&aLb 	+&eLf 	)&iLj 	'&mLn 	#&qLr 	%&uLv 	#yLz 	,}L~ 	&ALB 	%"ELF 	,"ILJ 	$"MLN 	%"QLR 	&"ULV 	 "YLZ 	)"]L^ 	'"aLb 	-"eLf 	!0iLj 	(0mLn 	0qLr 	-0uLv 	%0yLz 	3-}L~ 	6-ALB 	&)ELF 	&)ILJ 	%)MLN 	%)QLR 	))ULV 	))YLZ 	0)]L^ 	+)aLb 	+)eLf 	))iLj 	))mLn 	/)qLr 	.)uLv 	 )yLz 	)}L~ 	)ALB 	)ELF 	#)ILJ 	")MLN 	))QLR 	()ULV 	()YLZ 	')]L^ 	+)aLb 	*)eLf 	+)iLj 	*)mLn 	%)qLr 	$)uLv 	#)yLz 	()}L~ 	))ALB 	')ELF 	()ILJ 	(MLN 	QLR 	*ULV 	$YLZ 	]L^ 	,aLb 	.eLf 	#iLj 	mLn 	qLr 	uLv 	0yLz 	'}L~ 	*ALB 	*ELF 	1ILJ 	MLN 	QLR 	,ULV 	%YLZ 	3]L^ 	%aLb 	3eLf 	iLj 	)mLn 	*qLr 	uLv 	-yLz 	)}L~ 	(ALB 	!ELF 	&ILJ 	MLN 	$QLR 	-ULV 	(YLZ 	]L^ 	!aLb 	*eLf 	%iLj 	-mLn 	0qLr 	3uLv 	+yLz 	0}L~ 	$A	LB	 	2E	LF	 	$I	LJ	 	2M	LN	 	EFQ	LZ	 	__ !]	Lf	 	1-i	Lj	 	)*m	Ln	 	2/q	Lr	 	,(u	Lx	 0'!4&91/ 3// 30%8.7&>W
LDZ
 44T5K5KL-DDJJL /


 !'v{ ;=g (/dV$/H"#""*+
H" 	#""*+
H" 	'#""*+)
H"& 	&#""*+(
'H"2 	. "$ %
3H"> 	. "$ %
?H"J 	. "$ %
KH"V 	. "5 6 
WH"b 	""'(
cH"n 	#=%
oH"t 	0""OP
2
uH"J 	%!!?@ >'
KH"b 	'=)
cH"h 	#!! >%
iH"z 	$=&
{H"@ 	 ""+,
AH"P 	# ""45%
QH"b !""01!
 !""34$
 !""<=-
AH"DR 44T5O5OP*g"')>g""$9g" 	-g" 	+	g"
 	-g" 	,g" 	)g" 	(g" 	(g" 	(g" 	2:g" 	#$@g" 	 9g" 	"#<g"  	#$=!g"" 	+,E#g"$ 	$%;%g"& 	$%;'g"( 	0)g". 	;/g"0 	Y&&,}(u341g"< 	**,z)JK=g"H 		)),z)JKIg"T 	**,,)0	1Ug"d 	():):,%*F	*Geg"t 	I--%"''&/+ug"| 	9,,%"''&/+}g"D 	5i6G6G3&7BEg"H 	#$AIg"J 	%&CKg"L 	'(EMg"N 	#$AOg"P 	4Y5F5F3'6CQg"T 	$%BUg"X 76::D8866::D&/&7&7%"''$-')Gg"DP 44T5O5OP5IIDr   c                    t        j                  t                     }|j                  |       t	        |j
                        }t        |v r:| j                  r.|s,t               j                  |       | j                  |d      S |rMi | _
        i | _        i | _        i | _        i | _        i | _        t         j"                  | _        i | _        i | _        ||j*                  |j,                  fS )NT)after_compat_v1_upgrade)r   PastaAnalyzeVisitorr   visitsetresultsr$   r  r(   
preprocessfunction_handler%  r  r  r(  r   r   rG  rH  rF  r  logwarnings_and_errors)r   	root_noderg  visitor
detectionss        r   rl  zTFAPIChangeSpec.preprocess  s    ++,C,EFGMM)W__%J 	J&4+H+H#$$Y/__Y_EE
 d!d&(d#d!d "d!7!K!Kd#%d dgkk7#>#>>>r   c                 R    | j                  | j                  | j                         y )N)r  r  )r   r  r  r   s    r   clear_preprocessingz#TFAPIChangeSpec.clear_preprocessing  s%    MM 2 2+/+H+H  Jr   N)FF)F)r   r   r   r1   r   rl  rt  r   r   r   r3   r3   U   s    ;DJL,?<Jr   r3   c                    t         j                  g}t        t         d      r|t         j                  gz  }t        t         d      r|t         j                  gz  }t        t         d      r|t         j
                  gz  }t        | |      S )z0Determine whether this node represents a string.Bytes	JoinedStrFormattedValue)r=  r>  hasattrrv  rw  rx  
isinstance)r.   allowed_typess     r   r9  r9    sl    77)-S'cii[ MS+cmm_$MS"#c(())M	D-	((r   c                     t        t        d      r*t        | t        j                        xr | j                  du S t        | t        j
                        xr | j                  dk(  S )NNameConstantTr  ry  r=  rz  r}  r   Nameidr.   s    r   r:  r:    sL    S.!dC,,-D$**2DDdCHH%;$''V*;;r   c                     t        t        d      r*t        | t        j                        xr | j                  du S t        | t        j
                        xr | j                  dk(  S )Nr}  Fr  r~  r  s    r   r;  r;    sL    S.!dC,,-E$**2EEdCHH%<$''W*<<r   c	                 Z   t        j                  ||      \  }	}
|	sy|r ||
      r|rt        |j                        D ]s  \  }}|j                  |k(  s|j                  j                  |       |j                  t         j                  |j                  |j                  d|d|xs |f        |S  |S y|j                  ddd      }t        j                  |      |_        |j                  t         j                  |j                  |j                  d|d|d	|d
||ndf       |S )a"  Replaces the given call with tf.compat.v1 if the given arg is found.

  This requires the function to be called with all named args, so for using
  this transformer, the function should also be added to renames.

  If the arg is not found, the call site is left alone.

  If the arg is found, and if arg_ok_predicate is given, it is called with
  the ast Expression representing the argument value found. If it returns
  True, the function is left alone.

  If the arg is found, arg_ok_predicate is not None and returns ok, and
  remove_if_ok is True, the argument is removed from the call.

  Otherwise, `compat.v1` is inserted between tf and the function name.

  Args:
    parent: Parent of node.
    node: ast.Call node to maybe modify.
    full_name: full name of function to modify
    name: name of function to modify
    logs: list of logs to append to
    arg_name: name of the argument to look for
    arg_ok_predicate: predicate callable with the ast of the argument value,
      returns whether the argument value is allowed.
    remove_if_ok: remove the argument if present and ok as determined by
      arg_ok_predicate.
    message: message to print if a non-ok arg is found (and hence, the function
      is renamed to its compat.v1 version).

  Returns:
    node, if it was modified, else None.
  NRemoved argument  for function tf.tf.compat.v1.   z	Renaming  to z because argument z is present.  )r   get_arg_value	enumeratekeywordsargpopappendr   lineno
col_offsetreplacefull_name_nodefunc)parentr.   	full_namer+   logsr  r  r  rq   arg_present	arg_valueikwnew_names                 r   r8  r8    s!   N %224B+y	
 *95T]]+ %!R66X
--

A

++y~~t{{DOO#Y%6$%689 : k k uoq9(&&x0$)++nndkk4??(H1Dg"&LN 
 
+r   c           
      *   |j                   j                  t        j                  ||             |j                  t        j
                  |j                  |j                  dt        j                  |j                   d         d|xs |df       |S )z;Adds an argument (as a final kwarg arg_name=arg_value_ast).r  r   zAdding argument 'z' to call to .)
r  r  r=  keywordr   r   r  r  pastadump)r  r.   r  r+   r  r  r  s          r   r<  r<  d  sr     --s{{x}EF++nndkk4??/4zz$--:K/L/8/@D/@B 
 
+r   c           
         |r#|j                  d      s|j                  d      ryt        |j                  t        j                        sy|j                  j
                  g|j                  z   |_        t        j                  d      |j                  _        |j                  t        j                  |j                  |j                  d|d|df       |S )z4Transform iterator methods to compat function calls.ztf.compat.v1.dataztf.dataNzChanging dataset.z() to tf.compat.v1.data.z-(dataset). Please check this transformation.
)
startswithrz  r  r=  	Attributer   argsr   r  r  r'  r  r  )r  r.   r  r+   r  s        r   r-  r-  p  s     I(()<=((3
 
DIIs}}	-
 yy$))+$),,-@A$))/++y  $++t8<dDE F 
+r   c                    d }|j                   D ]f  }|j                  dk(  s|j                  t        j                  |j
                  |j                  df       d|_         |||j                         |c S  t        |j                        dk  r8|j                  t        j                  |j
                  |j                  df       y
t        j                  d|j                  d         } |||j                         |j                   j                  |       |j                  d= |j                  t        j                  |j
                  |j                  d	f       |S )zReplace keep_prob with 1-rate.c                    t        j                  d      }d|_        d|_        t        j                  |t        j
                         |      }t        j                  j                  | ||       t        j                  ||       t        j                  j                  j                  |dd       t        j                  j                  j                  |dd       y	)
z&Replaces old_value with 1-(old_value).r  nr   leftoprightprefix(suffix)N)r=  Numr  r  BinOpSubr  	ast_utilsreplace_childcopy_locationbase
formattingrj  )r  	old_valueone	new_values       r   _replace_keep_prob_nodez5_dropout_transformer.<locals>._replace_keep_prob_node  s    
''A,CCJCN		sswwy )+I 
OO!!&)Y?i+ 
JJi37	JJi37r   	keep_probz0Changing keep_prob arg of tf.nn.dropout to rate
rm   r  ztf.nn.dropout called without arguments, so automatic fix was disabled. tf.nn.dropout has changed the semantics of the second argument.r  r  zHChanging keep_prob arg of tf.nn.dropout to rate, and recomputing value.
N)r  r  r  r   r   r  r  r   lenr  r
   r=  r  )r  r.   r  r+   r  r  r  rate_args           r   r.  r.    s   8  == i}}#
kk9>>4;;FH Iimi9k 	^aKK$++t9: ;
 {{vTYYq\:HHhnn5MM"		!KKdoo() * Kr   c           
         |dd }|dk(  rd}n|dk(  rd}t        j                  dt        j                  t        j                  dt        j                         	      |t        j                         
            }t        |j                        dk(  rSt        j                  d|j                  d         }|j                  dd |_        |j                  j                  |       |j                  |j                  _	        |j                  dz   |j                  _        |j                  j                  |       t        |j                  t         j                        rd|j                  _        n7t        |j                  t         j                        sJ d|j                  _        |j                  t         j"                  |j                  |j                  d|d|df       |S )z7Transforms to_int and to_float to cast(..., dtype=...).r  Nfloatfloat32doublefloat64r   r!   r  ctxr   attrr  r  r  r+   r  d   castChanged z call to tf.cast(..., dtype=tf.).)r=  r  r  r  Loadr  r  r  r  r  r   r  rz  r  r  r  r   r   )r  r.   r  r+   r  	dtype_strnew_argname_args           r   r/  r/    sj    12h)'IHIKKG!mm#((d?Bxxz3K1:
LM'
 	^q{{v!%20H		#2DIMM" '--!__S0'----w		3==)DIINdii***DIIL++y~~t{{DOOBKBKMN O 
+r   c                     d }|j                   D ]_  }|j                  dk(  s |||j                        r7|j                  t        j
                  |j                  |j                  df       |c S  |S )z)Wrap labels argument with stop_gradients.c                    t        |t        j                        xr t        |j                  t        j                        xrn |j                  j
                  dk(  xrS t        |j                  j                  t        j                        xr# |j                  j                  j                  dk(  }|ry	 t        j                  t        j                  dt        j                               |gg       }t        j                  j                  | ||       t        j                  ||       y# t        $ rD t        j                  t        j                  dt        j                               |gg dd      }Y w xY w)z"Wrap labels with tf.stop_gradient.stop_gradientr!   Fztf.stop_gradientr  NT)rz  r=  Callr  r  r  r   r  r  r  	TypeErrorr  r  r  r  )r  r  already_stop_gradr  s       r   _wrap_labelzC_softmax_cross_entropy_with_logits_transformer.<locals>._wrap_label  s"   #Isxx8 9#INNCMMB9",,?9 $INN$8$8#((C9 #--00D8	 
 '((
(((chhj
9+ri 
OO!!&)Y?i+  '((
(((chhj
9+r4'i's   5?D, ,A
E98E9r   z~Changing labels arg of tf.nn.softmax_cross_entropy_with_logits to tf.stop_gradient(labels). Please check this transformation.
)r  r  r   r  r   r   r  r  )r  r.   r  r+   r  r  kargs          r   r0  r0    sl    0 mm dxx8	T4::	&Y^^T[[$//)* 	+
 k 
+r   c                    |dd j                         }t        j                  dt        j                  t        j                  t        j                  t        j                  dt        j
                               dt        j
                               dt        j
                               |t        j
                               	      }t        |j                        d
k(  rSt        j                  d|j                  d   	      }|j                  dd |_        |j                  j                  |       t        |j                        dk(  r8t        j                  d|j                  d   	      }|j                  dd |_        g }|j                  D ]#  }	|	j                  dk7  s|j                  |	       % ||_        |j                  |j                  _        |j                  dz   |j                  _        |j                  j                  |       t        |j                  t        j                        rd|j                  _        n7t        |j                  t        j                        sJ d|j                  _        |j                  t$        j&                  |j                  |j                  d|d|df       |S )z>Transforms image.resize_* to image.resize(..., method=*, ...).   Nmethodr!   r  imager  ResizeMethodr  r  preserve_aspect_ratior  r  rP   r  resizer  z; call to tf.image.resize(..., method=tf.image.ResizeMethod.r  )upperr=  r  r  r  r  r  r  r  r  r  r  r   r  rz  r  r  r  r   r   )
r  r.   r  r+   r  resize_methodr  pos_argnew_keywordsr  s
             r   r2  r2    s   qr(.."-KKH!mm"%--&)mm*-((d
*K)0chhj'B &4	#E
 "/CHHJ@A' 	^qkk5 $		"/G		#2DIMM!^qkko $		"/G		#2DI,MM b	vv " $- '--!__S0'----w		3==)DIINdii***DIIL++y~~t{{DOO6?6CEF G 
+r   c                    d}d}d}g }|j                   D ]  }	t        j                  dd dk\  rt        |	t        j
                        rn|	j                  dk(  r|	}n|	j                  dk(  s|	j                  dk(  rt        |	d|j                        }
t        |	d	|j                        }|j                  t        j                  |
|d
|	j                  d|xs |f       |	j                  dk(  rt        |	j                        sd}d}|j                  |	        |r|x|j                  t	        j                  dt	        j                   d                   |j#                  t        j                  |j                  |j                  d|xs |z  f       n7|j#                  t        j$                  |j                  |j                  df       |r	||_         |S y)zBRemoves seed2 and deterministic, and adds non-zero seed if needed.NFr  )r  r  seedr>   deterministicr  r  r  r  T*   r  z<Adding seed=42 to call to %s since determinism was requestedzThe deterministic argument is deprecated for %s, pass a non-zero seed for determinism. The deterministic argument is present, possibly not False, and the seed is already set. The converter cannot determine whether it is nonzero, please check.)r  sysversion_inforz  r=  Starredr  getattrr  r  r  r   r   r;  r   r  r  addr'  )r  r.   r  r+   r  seed_argr  modifiedr  r  r  r  s               r   r3  r3  4  s    (-(,MM b
v%*R*E
	6	h	7	bff7r8T[[1f2|T__=j
kk9>>6:vvy0D023 4 
?	"RXX&-h!$ #++&DE
hh
..$++t
H4! 	 hh


T[[$//L 	  DMK
r   c                    d }|j                   D ]v  }|j                  dk(  s|j                  t        j                  |j
                  |j                  df       d|_        |j                  rdnd} |||j                         |c S  t        |j                        dk\  rO |||j                  d          |j                  t        j                  |j
                  |j                  df       |S y )	Nc                    t        j                  d      }t        j                  d      }t        j                  |||      }t        j                  j                  | ||       t        j                  ||       t        j                  j                  j                  |j                  dd       t        j                  j                  j                  |j                  dd       y	)
z0Replaces old_value with 'uniform' or 'gaussian'.uniform)sgaussian)bodytestorelser  r  r  r  N)r=  r>  IfExpr  r  r  r  r  r  rj  r  )r  r  r  r  r  s        r   _replace_uniform_noise_nodezA_extract_glimpse_transformer.<locals>._replace_uniform_noise_nodeh  s    gg	"Gww$H		wYxHI	OO!!&)Y?i+ 
JJinnh<	JJinnh<r   uniform_noisezzChanging uniform_noise arg of tf.image.extract_glimpse to noise, and recomputing value. Please check this transformation.
noiser  r  r  zXChanging uniform_noise arg of tf.image.extract_glimpse to noise, and recomputing value.
)
r  r  r  r   r   r  r  r   r  r  )r  r.   r  r+   r  r  r  r   s           r   r1  r1  f  s    = }} 	mO+
kk9>>4;;'( ) "m(..iJe!-1D1DEk	 	^qdiil3KKdoo34 5 K r   c           
         |j                   D ]  }|j                  dk(  s|c S  d}t        j                  |      j                  d   j
                  }|`|j                   j                  t        j                  d|             |j                  t        j                  |j                  |j                  d|xs |d|df       |S )zAdds a step argument to the summary API call if not specified.

  The inserted argument value is tf.compat.v1.train.get_or_create_global_step().
  r   z.tf.compat.v1.train.get_or_create_global_step()r   r  zSummary API writing function z6 now requires a 'step' argument; inserting default of r  )r  r  r=  parser  r   r  r  r  r   r'  r  )r  r.   r  r+   r  keyword_argdefault_value	ast_values           r   r@  r@    s    
 ]] k& k C-ii&++A.44)--s{{vY?@++doo$-$5$5}FG H 
+r   c           
          |j                   j                  t        j                  |             |j                  t        j
                  |j                  |j                  d|d|xs |df       |S )zAdds cond argument to tf.contrib.summary.xxx_record_summaries().

  This is in anticipation of them being renamed to tf.summary.record_if(), which
  requires the cond argument.
  zAdding `z` argument to zH in anticipation of it being renamed to tf.compat.v2.summary.record_if())r  r  r  r   r   r   r  r  )r  r.   r  r+   r  r  s         r   r?  r?    s_     ))5;;t$%++nndkk4??,0)2Ct2CEF G 
+r   c	                 F    |D ]  }	t        | |||||	|||	      }
|
r|
n|} |S )a  Replaces the given call with tf.compat.v1 if any of the arg_names is found.

  Args:
    parent: Parent of node.
    node: ast.Call node to modify.
    full_name: full name of function to modify.
    name: name of function to modify.
    logs: list of logs to append to.
    arg_names: list of names of the argument to look for.
    arg_ok_predicate: predicate callable with the ast of the argument value,
      returns whether the argument value is allowed.
    remove_if_ok: remove the argument if present and ok as determined by
      arg_ok_predicate.
    message: message to print if a non-ok arg is found (and hence, the function
      is renamed to its compat.v1 version).

  Returns:
    node, if it was modified, else None.
  r8  r  r.   r  r+   r  	arg_namesr  r  rq   r  rename_nodes              r   $_rename_if_any_arg_found_transformerr
    sF    :  0h2643<dD3;=M3?JK &;4D0 
+r   c	                 F    |D ]  }	t        | |||||	|||	      }
|
r|
n|} |S )a  Combination of _rename_if_arg_found and _add_loss_reduction transformers.

  Args:
    parent: Parent of node.
    node: ast.Call node to maybe modify.
    full_name: full name of function to modify
    name: name of function to modify
    logs: list of logs to append to
    arg_names: list of names of the argument to look for
    arg_ok_predicate: predicate callable with the ast of the argument value,
      returns whether the argument value is allowed.
    remove_if_ok: remove the argument if present and ok as determined by
      arg_ok_predicate.
    message: message to print if a non-ok arg is found (and hence, the function
      is renamed to its compat.v1 version).

  Returns:
    node, if it was modified, else None.
  r  r  s              r   7_rename_if_arg_found_and_add_loss_reduction_transformerr    sE    <  0h26437x3C3?JK &;4D0 
+r   c                 :   |j                   D ]  }|j                  dk(  sd|_         d}t        j                  |      }|j                   j	                  t        j                  d|             |j                  j                  j                  }|j                  j                  j                  }	t        j                  d      |j                  _        ||j                  j                  _	        |	|j                  j                  _
        d|j                  _        |S )aR  Updates references to uniform_unit_scaling_initializer.

  Transforms:
  tf.uniform_unit_scaling_initializer(factor, seed, dtype) to
  tf.compat.v1.keras.initializers.VarianceScaling(
      scale=factor, distribution="uniform", seed=seed)

  Note: to apply this transformation, symbol must be added
  to reordered_function_names above.
  factorscale	"uniform"distributionr  tf.compat.v1.keras.initializersVarianceScaling)r  r  r  r   r  r=  r  r  r   r  r  r   r  r  )
r  r.   r  r+   r  r  distribution_valuer  r  r  s
             r   rE  rE    s     ]]  k("ko  %kk,-)--s{{~YGH99??!!&yy))*,,-NO$))/!$))//)$))//$$)).	+r   c                    d }d}|j                   D ]  }|j                  dk(  sd}d|_        |j                  } ||j                        }	t        j                  j                  |||	       t        j                  j                  j                  |j                  dd       t        j                  j                  j                  |j                  dd	        g }
t        j                  d
      }|
j                  t        j                  d|             t        j                  d      }|
j                  t        j                  d|             t        |j                        dk\  r=d} ||j                  d         }|
j                  t        j                  d|             |s;t        j                  d      }|
j                  t        j                  d|             t        |j                        dk\  r3|
j                  t        j                  d|j                  d                t        |j                        dk\  r3|
j                  t        j                  d|j                  d                g |_        |
|j                   z   |_         |j                  j                  j                   }|j                  j                  j"                  }t%        j&                  d      |j                  _        ||j                  j                  _        ||j                  j                  _        d|j                  _        |j                  t$        j*                  |j                   |j"                  df       |S )aX  Updates references to contrib.layers.xavier_initializer.

  Transforms:
  tf.contrib.layers.xavier_initializer(uniform, seed, dtype) to
  tf.compat.v1.keras.initializers.VarianceScaling(
      scale=1.0, mode="fan_avg",
      distribution=("uniform" if uniform else "truncated_normal"),
      seed=seed, dtype=dtype)

  Returns: The new node
  c                 d   t        j                  d      }|j                  d   j                  }t         j                  j                  ||j                  |        t         j                  j                  j                  |dd       t         j                  j                  j                  |dd       |S )zbReturns an AST matching the following:
    ("uniform" if (old_value) else "truncated_normal")
    ."uniform" if old_value else "truncated_normal"r   r  r  r  r  
r  r   r  r   r  r  r  r  r  rj  )r  distifexprs      r   _get_distributionzI_contrib_layers_xavier_initializer_transformer.<locals>._get_distribution'  s}     ;;KLDYYq\F	OO!!&&++yA	JJdHc2	JJdHc2Kr   Fr  Tr  r  r  r  r  z1.0r  r  z	"fan_avg"moder  r   r  r  r  r  r   r  r  z}Changing tf.contrib.layers xavier initializer to a tf.compat.v1.keras.initializers.VarianceScaling and converting arguments.
)r  r  r   r  r  r  r  r  rj  r   r  r=  r  r  r  r  r  r  r   r  r  r   )r  r.   r  r+   r  r  found_distributionr  r  r  r  r  r  r  uniform_distr  r  s                    r   rC  rC    s    ]] Bk)#&ko##i#K$5$56ioo##KIFjj 1 18SAjj 1 18SAB ,
++e
%ckkgU;<	]	#$ckkfD9:^qTYYq\*DdCD	;;}-LlKL^qdiilCD^qtyy|DE$).$-99??!!&yy))*,,-NO$))/!$))//)$))//$$)).++y~~t{{DOO*+ ,
 
+r   c                 2   d }d }d}|j                   D ]f  }|j                  dk(  r	d|_        d}|j                  dk(  r |||j                         |j                  dk(  sMd	|_         |||j                         h t        |j                        d
k\  rd}t        |j                        dk\  r |||j                  d
          t        |j                        dk\  r |||j                  d          |s?t        j                  d      }	t        j                  d|	      g|j                   z   |_         |j                  j                  j                  }
|j                  j                  j                  }t        j                  d      |j                  _        |
|j                  j                  _
        ||j                  j                  _        d|j                  _        |j                  t        j                   |j                  |j                  df       |S )a  Updates references to contrib.layers.variance_scaling_initializer.

  Transforms:
  tf.contrib.layers.variance_scaling_initializer(
    factor, mode, uniform, seed, dtype
  ) to
  tf.compat.v1.keras.initializers.VarianceScaling(
      scale=factor, mode=mode.lower(),
      distribution=("uniform" if uniform else "truncated_normal"),
      seed=seed, dtype=dtype)

  And handles the case where no factor is provided and scale needs to be
  set to 2.0 to match contrib's default instead of tf.keras.initializer's
  default of 1.0
  c                    t        j                  d      }|j                  d   j                  }t         j                  j                  ||j                  |       t         j                  j                  | ||       t         j                  j                  j                  |dd       t         j                  j                  j                  |dd       y)zFReplaces old_value: ("uniform" if (old_value) else "truncated_normal")r  r   r  r  r  r  Nr  )r  r  r  r  s       r   _replace_distributionzW_contrib_layers_variance_scaling_initializer_transformer.<locals>._replace_distributiony  s    <>I^^A$$F	OO!!&&++yA	OO!!&)Y?	JJi37	JJi37r   c                    t        j                  d      }|j                  d   j                  j                  }t         j
                  j                  ||j                  |       t         j
                  j                  | ||       t         j                  j                  j                  |dd       t         j                  j                  j                  |dd       y)z,Replaces old_value with (old_value).lower().zmode.lower()r   r  r  r  r  N)
r  r   r  r   r  r  r  r  r  rj  )r  r  r  r  s       r   _replace_modezO_contrib_layers_variance_scaling_initializer_transformer.<locals>._replace_mode  s    N+I>>!""''D	OO!!$

I> 
OO!!&)Y? 
JJi37	JJi37r   Fr  r  Tr  r  r  r  r  r  z2.0r  r  r  zChanging tf.contrib.layers.variance_scaling_initializer to a tf.compat.v1.keras.initializers.VarianceScaling and converting arguments.
)r  r  r   r  r  r  r   r=  r  r  r  r  r   r  r  r  r   )r  r.   r  r+   r  r!  r#  found_scaler  scale_valuer  r  s               r   rD  rD  h  s   "
88  +]] <k("kok& K!2!23)#&koK):):;< 	^qK^q$		!%^q$		!- 
++e$Kkkg[AB}}%DM 99??!!&yy))*,,-NO$))/!$))//)$))//$$)).++y~~t{{DOO*+ ,
 
+r   c                    d}|j                   D ]a  }|j                  dk(  r>|j                  t        j                  |j
                  |j                  df       d|_        |j                  dk(  s`|}c |rR|j                  t        j                  |j
                  |j                  df       |j                   j                  |       t        |j                        dkD  rK|j                  dd |_	        |j                  t        j                  |j
                  |j                  df       |j                  j                  j
                  }|j                  j                  j                  }t        j                  d      |j                  _        ||j                  j                  _        ||j                  j                  _        d	|j                  _        |S )
zReplace slim l1 regularizer with Keras one.

  This entails renaming the 'scale' arg to 'l' and dropping any
  provided scope arg.
  Nr  z"Renaming scale arg of regularizer
lscopezpDropping scope arg from tf.contrib.layers.l1_regularizer, because it is unsupported in tf.keras.regularizers.l1
r  tf.keras.regularizersl1)r  r  r  r   r   r  r  remover  r  r  r   r  r  )	r  r.   r  r+   r  scope_keywordr  r  r  s	            r   rA  rA    se    - g{{g
kk9>>4;;8: ;gk{{gm KKdooLM N 	MM'^a		"1DIKKdooLM N 99??!!&yy))*,,-DE$))/!$))//)$))//$)).	+r   c                 6   d }d}|j                   D ]=  }|j                  dk(  rd|_         |||j                         |j                  dk(  s<|}? t        |j                        dk\  r |||j                  d          |rR|j                  t        j                  |j                  |j                  df       |j                   j                  |       t        |j                        dkD  rK|j                  dd |_        |j                  t        j                  |j                  |j                  df       |j                  t        j                  |j                  |j                  d	f       |j                  j                  j                  }|j                  j                  j                  }	t        j                  d
      |j                  _        ||j                  j                  _        |	|j                  j                  _	        d|j                  _        |S )zbReplace slim l2 regularizer with Keras one, with l=0.5*scale.

  Also drops the scope argument.
  c                    t        j                  d      }d|_        d|_        t        j                  |t        j
                         |      }t        j                  j                  | ||       t        j                  j                  j                  |dd       t        j                  j                  j                  |dd       y	)
z(Replaces old_value with 0.5*(old_value).g      ?r  r   r  r  r  r  r  N)r=  r  r  r  r  Multr  r  r  r  r  rj  )r  r  halfr  s       r   _replace_scale_nodezG_contrib_layers_l2_regularizer_transformer.<locals>._replace_scale_node  s    77S>DDKDO		t
 )+I 
OO!!&)Y? 
JJi37	JJi37r   Nr  r'  r(  r  r   zpDropping scope arg from tf.contrib.layers.l2_regularizer, because it is unsupported in tf.keras.regularizers.l2
zlMultiplying scale arg of tf.contrib.layers.l2_regularizer by half to what tf.keras.regularizers.l2 expects.
r)  l2)r  r  r   r  r  r  r   r   r  r  r+  r  r  r  )
r  r.   r  r+   r  r1  r,  r  r  r  s
             r   rB  rB    s   8  - g{{ggk'7==1{{gm 	^qdiil+ KKdooLM N 	MM'^a		"1DIKKdooLM N ++y~~t{{DOOFG H 99??!!&yy))*,,-DE$))/!$))//)$))//$)).	+r   c           	         t        j                  |dd      \  }}t        j                  |dd      \  }}|rt        j                  |      dk7  r|j	                  t         j
                  |j                  |j                  df       d}|j	                  t         j
                  |j                  j                  |j                  j                  d|d	|f       t        j                  ||j                  j                        }	t        j                  |	|j                         t        j                  j                  ||j                  |	       |S |r]|j	                  t         j
                  |j                  |j                  d
f       g |_        t        j                   d|      g|_        |S |j	                  t         j$                  |j                  |j                  df       y)zGFix name scope invocation to use 'default_name' and omit 'values' args.r+   r   default_namer  Nonez`name` passed to `name_scope`. Because you may be re-entering an existing scope, it is not safe to convert automatically,  the v2 name_scope does not support re-entering scopes by name.
ztf.compat.v1.name_scopeRenamed r  z2Using default_name as name in call to name_scope.
r  zPname_scope call with neither name nor default_name cannot be converted properly.N)r   r  r  r  r  r   r  r  r  r  r  r=  r  r  r  r  r  r  r
   )
r  r.   r  r+   r  
name_founddefault_foundr4  r  new_name_nodes
             r   r4  r4  !	  sv    ,,T61=*d ) 7 7na P- EJJt$.KKdoo  )HKK!1!14993G3G'0(;= >,,Xtyy}}EMmTYY/	OO!!$		=AK 	KKdooFH I DI[[V<@ADMK++yT__%& 'r   c                 F    |j                  ddd      }t        | ||||      S )Nr  r  r  )r  _rename_func)r.   r  r  reasonr  s        r   _rename_to_compat_v1r=  G	  s)    uoq9(	dIxv	>>r   c                 p   |j                  t        j                  | j                  | j                  d|d|d|f       t        j
                  || j                  j                        }t        j                  || j                         t        j                  j                  | | j                  |       | S )Nr6  r  z: )r  r   r   r  r  r  r  r  r=  r  r  r  r  )r.   r  r  r  r<  r9  s         r   r;  r;  L	  s~    ++y~~t{{DOO)2HfEG H**8TYY]]C-M499-//dii?	+r   c                    t        |j                        D ]  \  }}|j                  dk(  st        |j                        rT|j                  t        j                  |j                  |j                  df       |j                  j                  |        nt        |||d      c S  d}t        |j                        D ]  \  }}|j                  dk(  sd}t        |j                  t        j                        rE|j                  j                  dk(  sVt!        ||d|d	      }|j                  j                  |       t        |||d
      c S  |st        |||d      S t#        | ||||      S )zGUpdate tf.string_split arguments: skip_empty, sep, result_type, source.
skip_emptyz0removed argument skip_empty for tf.string_split.zFtf.string_split's replacement no longer takes the skip_empty argument.FsepTr  ztf.strings.bytes_splitz;Splitting bytes is not handled by tf.strings.bytes_split().zThe semantics for tf.string_split's sep parameter have changed when sep is the empty string; but sep is not a string literal, so we can't tell if it's an empty string.zThe semantics for tf.string_split's sep parameter have changed when sep unspecified: it now splits on all whitespace, not just the space character.)r  r  r  r;  r   r  r   r   r  r  r  r=  rz  r=  r>  r  r;  r5  )r  r.   r  r+   r  r  r  	found_seps           r   _string_split_transformerrC  U	  s[    ' 
.ea	vv	rxx	 Y^^T[[$//GI 	J!#)T $-. 	.
. )' 9ea	vvi	BHHcgg	&88::I7KM$ --

A
#)T89 	99 
i	    
)y$	MMr   c                 $   d}t        |j                        D ]  \  }}|j                  dk(  st        |j                  t
        j                        r|j                  j                  dv r|j                  t        j                  |j                  |j                  d|j                  j                  d|xs |f       |j                  j                  |       |j                  j                  dk(  rd}nt        |||d|z        c S  n t        |j                        D ]  \  }}|j                  d	k(  sd
|_         |rt        | t
        j                        r| j                   dk(  ry|j                  t        j                  |j                  |j                  df       t        j                  t#        j$                  |      d      }	 t        j&                  |g g       }|S |S # t(        $ r t        j&                  |g g dd      }Y |S w xY w)z7Update tf.strings.split arguments: result_type, source.Tresult_type)RaggedTensorSparseTensorzRemoved argument result_type=r  rF  Fz-%s no longer takes the result_type parameter.sourcerb   	to_sparseNzhAdding call to RaggedTensor.to_sparse() to result of strings.split, since it now returns a RaggedTensor.)r   r  )r  r  r  rz  r   r=  r>  r  r  r   r   r  r  r  r=  r  r  copydeepcopyr  r  )r  r.   r  r+   r  need_to_sparser  r  s           r   r5  r5  	  s    .' ea	vv
RXXsww
'
((**8
8Y^^T[[$//hhjj)"3t"356 	7 	!88::' .#)T;iGI 	I   ' ea	vvbf 63==)fkk[.HKK	doo
0	12 ==t}}T2ED0XXdB#d 
++  0XXdBD$/d	+0s   G) )"HH)NNFN)0r1   r=  rJ  r6  r  r  tensorflow.tools.compatibilityr   r   r   r   AnalysisResultr   r   r$   r%   APIAnalysisSpecr   NodeVisitorr(   NoUpdateSpecr3   r9  r:  r;  r8  r<  r-  r.  r/  r0  r2  r3  r1  r@  r?  r
  r  rE  rC  rD  rA  rB  r4  r=  r;  rC  r5  r   r   r   <module>rR     s\   I 
   
  9 4 A 6E	00 E<	00 < %[1 $[1 i77 S__ (iJi,, iJX-	)<= /36:27-1	BJ	4)X$N$N-`/d#J&* $Z %P<K\Sl$N9x#'L?
(NV'r   