o
    ®Ÿ?e
  ã                   @   s<   d Z ddlmZ ddlmZ daedƒdd„ ƒZdd	„ Zd
S )zPython debug mode enabler.é    )Úcontext)Ú	tf_exportFz#data.experimental.enable_debug_modec                   C   s   t  ¡ r
tdƒ dS tdƒ‚)a  Enables debug mode for tf.data.

  Example usage with pdb module:
  ```
  import tensorflow as tf
  import pdb

  tf.data.experimental.enable_debug_mode()

  def func(x):
    # Python 3.7 and older requires `pdb.Pdb(nosigint=True).set_trace()`
    pdb.set_trace()
    x = x + 1
    return x

  dataset = tf.data.Dataset.from_tensor_slices([1, 2, 3])
  dataset = dataset.map(func)

  for item in dataset:
    print(item)
  ```

  The effect of debug mode is two-fold:

  1) Any transformations that would introduce asynchrony, parallelism, or
  non-determinism to the input pipeline execution will be forced to execute
  synchronously, sequentially, and deterministically.

  2) Any user-defined functions passed into tf.data transformations such as
  `map` will be wrapped in `tf.py_function` so that their body is executed
  "eagerly" as a Python function as opposed to a traced TensorFlow graph, which
  is the default behavior. Note that even when debug mode is enabled, the
  user-defined function is still traced  to infer the shape and type of its
  outputs; as a consequence, any `print` statements or breakpoints will be
  triggered once during the tracing before the actual execution of the input
  pipeline.

  NOTE: As the debug mode setting affects the construction of the tf.data input
  pipeline, it should be enabled before any tf.data definitions.

  Raises:
    ValueError: When invoked from graph mode.
  Tz5`enable_debug_mode() is only supported in eager mode.N)r   Zexecuting_eagerlyÚtoggle_debug_modeÚ
ValueError© r   r   úf/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/data/ops/debug_mode.pyÚenable_debug_mode   s   -r   c                 C   s   | a d S )N)Ú
DEBUG_MODE)Ú
debug_moder   r   r   r   K   s   r   N)Ú__doc__Ztensorflow.python.eagerr   Z tensorflow.python.util.tf_exportr   r	   r   r   r   r   r   r   Ú<module>   s   
2