
    AVh                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddZ edd      ej&                  ej(                  dd                     Zy)z-Assert functions for Control Flow Operations.    )context)dtypes)errors)ops)	array_ops)cond)gen_control_flow_ops)gen_logging_ops)gen_math_ops)dispatch)tf_should_use)	tf_exportNc                    |d}n|dk  rt        j                  |       }| j                         rd| j                         j	                  d      }|d| D cg c]  }t        |       }}t        |      |j                  k  rE|j                  d       n3t        j                  |d      rt        | j                               g}ng }dj                  |      S c c}w )zReturns a summarized string representation of eager `tensor`.

  Args:
    tensor: EagerTensor to summarize
    summarize: Include these many first elements of `array`
  N   r   )z...z, )r   size_ranknumpyreshapestrlenappendr   	not_equaljoin)tensor	summarizeflatxlsts        Y/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/control_flow_assert.py_summarize_eagerr!      s     I1}v&I \\^<<>!!%(D
+
,a3q6
,C
,
3x$))	jj i+ !cc	3 -s   Czdebugging.AssertAssertc           
          t        j                         r^ s[t        j                        }|D cg c]  }t	        |       }}t        j                  ddd ddj                  |            yt        j                  |d g      5 }t        j                        }t        d |D              r"t        j                   d      cddd       S t        j                   d	        fd
}t        j                   t        j                  |d      }t        j                         r
	 ddd       y|j                   cddd       S c c}w # 1 sw Y   yxY w)a  Asserts that the given condition is true.

  If `condition` evaluates to false, print the list of tensors in `data`.
  `summarize` determines how many entries of the tensors to print.

  Args:
    condition: The condition to evaluate.
    data: The tensors to print out when condition is false.
    summarize: Print this many entries of each tensor.
    name: A name for this operation (optional).

  Returns:
    assert_op: An `Operation` that, when executed, raises a
    `tf.errors.InvalidArgumentError` if `condition` is not true.
    @compatibility(eager)
    returns None
    @end_compatibility

  Raises:
    @compatibility(TF1)
    When in TF V1 mode (that is, outside `tf.function`) Assert needs a control
    dependency on the output to ensure the assertion executes:

  ```python
  # Ensure maximum element of x is smaller or equal to 1
  assert_op = tf.Assert(tf.less_equal(tf.reduce_max(x), 1.), [x])
  with tf.control_dependencies([assert_op]):
    ... code using x ...
  ```

    @end_compatibility
  Nz
Expected 'z' to be true. Summarized data: 
)node_defopmessager"   c              3   t   K   | ]0  }|j                   t        j                  t        j                  hv  2 y wN)dtyper   stringint32).0r   s     r    	<genexpr>zAssert.<locals>.<genexpr>o   s&     
@177v}}fll33
@s   68name	Conditionc                  6    t        j                   d      S )Nr"   r/   )r
   _assert)	conditiondatar   s   r    true_assertzAssert.<locals>.true_assertw   s    &&tYX7 	7    AssertGuard)r   executing_eagerlyr   convert_n_to_tensorr!   r   InvalidArgumentErrorr   
name_scopeallr
   r3   convert_to_tensorr   r	   no_opr&   )	r4   r5   r   r0   xsr   data_strr6   guarded_asserts	   ```      r    r"   r"   >   sF   H  ""4(b:<=Q"1i0=h=''dii)+, ,
 
~~dHy$&78 D		 	 	&B

@R
@@ $$YihO  ''	Di7 yy


$
$
	n
 
	"	"	$) * +  > s   EA EAE<EEr)   )NN)__doc__tensorflow.python.eagerr   tensorflow.python.frameworkr   r   r   tensorflow.python.opsr   r   r	   r
   r   tensorflow.python.utilr   r    tensorflow.python.util.tf_exportr   r!   add_dispatch_supportshould_use_resultr"    r7   r    <module>rL      sm    4 + . . + + & 6 1 . + 0 6> x(	  A !  )Ar7   