
    ij.                     R    d Z ddlZ	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZy)z&TensorFlow Debugger (tfdbg) Utilities.    Nc                 Z   | j                   j                  }|| j                   _        |j                         }||_        ||_        ||_        t        |t              r|g}|j                  j                  |       |r/t        |t              r|g}|j                  j                  |       yy)a  Add watch on a `Tensor` to `RunOptions`.

  N.B.:
    1. Under certain circumstances, the `Tensor` may not get actually watched
      (e.g., if the node of the `Tensor` is constant-folded during runtime).
    2. For debugging purposes, the `parallel_iteration` attribute of all
      `tf.while_loop`s in the graph are set to 1 to prevent any node from
      being executed multiple times concurrently. This change does not affect
      subsequent non-debugged runs of the same `tf.while_loop`s.

  Args:
    run_options: An instance of `config_pb2.RunOptions` to be modified.
    node_name: (`str`) name of the node to watch.
    output_slot: (`int`) output slot index of the tensor from the watched node.
    debug_ops: (`str` or `list` of `str`) name(s) of the debug op(s). Can be a
      `list` of `str` or a single `str`. The latter case is equivalent to a
      `list` of `str` with only one element.
      For debug op types with customizable attributes, each debug op string can
      optionally contain a list of attribute names, in the syntax of:
        debug_op_name(attr_name_1=attr_value_1;attr_name_2=attr_value_2;...)
    debug_urls: (`str` or `list` of `str`) URL(s) to send debug values to,
      e.g., `file:///tmp/tfdbg_dump_1`, `grpc://localhost:12345`.
    tolerate_debug_op_creation_failures: (`bool`) Whether to tolerate debug op
      creation failures by not throwing exceptions.
    global_step: (`int`) Optional global_step count for this debug tensor
      watch.
  N)debug_optionsdebug_tensor_watch_optsglobal_stepadd#tolerate_debug_op_creation_failures	node_nameoutput_slot
isinstancestr	debug_opsextend
debug_urls)	run_optionsr	   r
   r   r   r   r   
watch_optswatchs	            |/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/tensorflow/python/debug/lib/debug_utils.pyadd_debug_tensor_watchr      s    F ((@@**5+'
..
%) +%/!%	3I//#*c"<j	J'	     c
                    |st        d      |st        d      t        |t              r|g}|rt        j                  |      nd}
|rt        j                  |      nd}|rt        j                  |      nd}|j                         }|D ]  }|j                  s|j                  }|j                  }|
r|
j                  |      s<|r|j                  |      sPt        t        |j                              D ]I  }|r3|j                  |j                  |   j                  j                        s8t        | ||||||       K  |
 xr | xr | }|rt        | dd||||       |	| j                  _        y)aa	  Add debug watches to `RunOptions` for a TensorFlow graph.

  To watch all `Tensor`s on the graph, let both `node_name_regex_allowlist`
  and `op_type_regex_allowlist` be the default (`None`).

  N.B.:
    1. Under certain circumstances, the `Tensor` may not get actually watched
      (e.g., if the node of the `Tensor` is constant-folded during runtime).
    2. For debugging purposes, the `parallel_iteration` attribute of all
      `tf.while_loop`s in the graph are set to 1 to prevent any node from
      being executed multiple times concurrently. This change does not affect
      subsequent non-debugged runs of the same `tf.while_loop`s.


  Args:
    run_options: An instance of `config_pb2.RunOptions` to be modified.
    graph: An instance of `ops.Graph`.
    debug_ops: (`str` or `list` of `str`) name(s) of the debug op(s) to use.
    debug_urls: URLs to send debug values to. Can be a list of strings,
      a single string, or None. The case of a single string is equivalent to
      a list consisting of a single string, e.g., `file:///tmp/tfdbg_dump_1`,
      `grpc://localhost:12345`.
      For debug op types with customizable attributes, each debug op name string
      can optionally contain a list of attribute names, in the syntax of:
        debug_op_name(attr_name_1=attr_value_1;attr_name_2=attr_value_2;...)
    node_name_regex_allowlist: Regular-expression allowlist for node_name,
      e.g., `"(weight_[0-9]+|bias_.*)"`
    op_type_regex_allowlist: Regular-expression allowlist for the op type of
      nodes, e.g., `"(Variable|Add)"`.
      If both `node_name_regex_allowlist` and `op_type_regex_allowlist`
      are set, the two filtering operations will occur in a logical `AND`
      relation. In other words, a node will be included if and only if it
      hits both allowlists.
    tensor_dtype_regex_allowlist: Regular-expression allowlist for Tensor
      data type, e.g., `"^int.*"`.
      This allowlist operates in logical `AND` relations to the two allowlists
      above.
    tolerate_debug_op_creation_failures: (`bool`) whether debug op creation
      failures (e.g., due to dtype incompatibility) are to be tolerated by not
      throwing exceptions.
    global_step: (`int`) Optional global_step count for this debug tensor
      watch.
    reset_disk_byte_usage: (`bool`) whether to reset the tracked disk byte
      usage to zero (default: `False`).
  z$debug_ops must not be empty or None.z%debug_urls must not be empty or None.Nr
   r   r   r   r   *)
ValueErrorr   r   recompileget_operationsoutputsnametypematchrangelendtyper   r   reset_disk_byte_usage)r   graphr   r   node_name_regex_allowlistop_type_regex_allowlisttensor_dtype_regex_allowlistr   r   r%   node_name_patternop_type_patterntensor_dtype_patternopsopr	   op_typeslotuse_node_name_wildcards                      r   watch_graphr2   M   s   n 

;
<<	
<
==	3I 
# 	jj*+(,  .Ebjj()$  
& 	jj-.+/  	# #b::IggG!2!8!8!C44W=c"**o& #
"((D)9)?)?)D)DE

1!###> !21 5 //5 44  ,O! 5J+1r   c
                 ~   t        |t              r|g}|rt        j                  |      nd}
|rt        j                  |      nd}|rt        j                  |      nd}|j	                         }|D ]  }|j
                  s|j                  }|j                  }|
r|
j                  |      r<|r|j                  |      rPt        t        |j
                              D ]I  }|r3|j                  |j
                  |   j                  j                        r8t        | ||||||       K |	| j                  _         y)aY  Add debug tensor watches, denylisting nodes and op types.

  This is similar to `watch_graph()`, but the node names and op types are
  denylisted, instead of allowlisted.

  N.B.:
    1. Under certain circumstances, the `Tensor` may not get actually watched
      (e.g., if the node of the `Tensor` is constant-folded during runtime).
    2. For debugging purposes, the `parallel_iteration` attribute of all
      `tf.while_loop`s in the graph are set to 1 to prevent any node from
      being executed multiple times concurrently. This change does not affect
      subsequent non-debugged runs of the same `tf.while_loop`s.

  Args:
    run_options: An instance of `config_pb2.RunOptions` to be modified.
    graph: An instance of `ops.Graph`.
    debug_ops: (`str` or `list` of `str`) name(s) of the debug op(s) to use. See
      the documentation of `watch_graph` for more details.
    debug_urls: URL(s) to send debug values to, e.g.,
      `file:///tmp/tfdbg_dump_1`, `grpc://localhost:12345`.
    node_name_regex_denylist: Regular-expression denylist for node_name. This
      should be a string, e.g., `"(weight_[0-9]+|bias_.*)"`.
    op_type_regex_denylist: Regular-expression denylist for the op type of
      nodes, e.g., `"(Variable|Add)"`. If both node_name_regex_denylist and
      op_type_regex_denylist are set, the two filtering operations will occur in
      a logical `OR` relation. In other words, a node will be excluded if it
      hits either of the two denylists; a node will be included if and only if
      it hits neither of the denylists.
    tensor_dtype_regex_denylist: Regular-expression denylist for Tensor data
      type, e.g., `"^int.*"`. This denylist operates in logical `OR` relations
      to the two allowlists above.
    tolerate_debug_op_creation_failures: (`bool`) whether debug op creation
      failures (e.g., due to dtype incompatibility) are to be tolerated by not
      throwing exceptions.
    global_step: (`int`) Optional global_step count for this debug tensor watch.
    reset_disk_byte_usage: (`bool`) whether to reset the tracked disk byte
      usage to zero (default: `False`).
  Nr   )r   r   r   r   r   r   r   r    r!   r"   r#   r$   r   r   r%   )r   r&   r   r   node_name_regex_denylistop_type_regex_denylisttensor_dtype_regex_denylistr   r   r%   r*   r+   r,   r-   r.   r	   r/   r0   s                     r   watch_graph_with_denylistsr7      s>   b 	3I 
" 	jj)*'+  -Cbjj'(  
% 	jj,-*.  	# Lb::IggG.44Y??009c"**o& #


$
$RZZ%5%;%;%@%@
A

1!## 7LK37Lr   )r   DebugIdentityNFr   )r8   NNNNFr   F)__doc__r   r   r2   r7    r   r   <module>r;      sg    - 	 ()%4&*?D')5(t **.(,-149&+uJt *9*.8<6:;?CH+-5:YLr   