
    BVh                         d 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
 ddl	mZ ddlmZ dd	lmZ d
 Zd Zej$                  fdZd Zy)z,Autograph specifc overrides for tf.data.ops.    N)control_flow)py_builtins)iterator_ops)tensor_conversion)tensor_spec)cond)nestc                    t        |t        j                        sJ t        t	        dj                  |             t        |t        t        t        t        t        j                  f      rt        j                  |      }t        |dd      }||j                  k7  r6|dn
t        |      }t!        dj                  | ||j                  |            y)aP  Verifies that a symbol has a type compatible vith a given spec.

  Here, compatibility is viewed in the general TensorFlow sense: that the dtypes
  are the same after implicit conversion, if both are tensors.

  This verifier ensures consistent treatment of types across AutoGraph.

  Args:
    input_name: A name to use for `input_` in error messages.
    spec_name: A name to use for `spec` in error messages.
    input_: Any, value to verify.
    spec: TypeSpec that `input_` must be compatible with.

  Raises:
    ValueError if the two types have been determined not to be compatible.
  Nz{} cannot be Nonedtypezno dtypez6{} must have the same dtype as {}. Expected {}, got {})
isinstancer   
TensorSpecinput
ValueErrorformatboolintfloatstrnpndarrayr   convert_to_tensor_v2getattrr   	TypeError)
input_name	spec_nameinput_specinput_dtypeinput_dtype_strs         ]/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/data/ops/iterator_autograph.py_verify_spec_compatibler!      s    " 
D+00	11	1
]
(//
;
<< sE3

;<33F;F.+DJJ$/$7jS=MO
@GG	4::	
      c           
         	 t        j                  ||d       t        j                  t        j                  t        | |      ||       y# t        t        f$ r+}t        dj	                  | |t        |                  |d}~ww xY w)a  Verifies that possibly-structured symbol has types compatible vith another.

  See _verify_spec_compatible for a more concrete meaning of "compatible".
  Unspec _verify_spec_compatible, which handles singular Tensor-spec objects,
  verify_structures_compatible can process structures recognized by tf.nest.

  Args:
    input_name: A name to use for `input_` in error messages.
    spec_name: A name to use for `spec` in error messages.
    input_: Any, value to verify. May, but doesn't need to, be a structure.
    spec: Any, value that `input_` must be compatible with. May, but doesn't
      need to, be a structure.

  Raises:
    ValueError if the two types have been determined not to be compatible.
  T)expand_compositesz2{} must have the same element structure as {}.

{}N)
r	   assert_same_structurer   r   r   r   map_structure	functoolspartialr!   )r   r   r   r   es        r    _verify_structure_compatibler*   D   s    "vttD /YG
 i	  
>EE	3q6	
 	s   A B&B  Bc                     t         j                  u rt        |       S | j                         }t	        dd| j
                         t        j                  |j                         |j                  fd      S )Nzthe default argumentzthe iteratec                       S N )defaults   r    <lambda>z#_next_tf_iterator.<locals>.<lambda>m   s    g r"   )	r   UNSPECIFIEDnextget_next_as_optionalr*   element_specr   	has_value	get_value)iteratorr/   opt_iterates    ` r    _next_tf_iteratorr9   c   sk    ''' >--/+mWh6K6K 
{44o
 r"   c                      t         j                  j                  t        j                  t
               t        j                  j                  t        j                  t        j                         y r-   )	r   next_registryregisterr   OwnedIteratorr9   r   for_loop_registry_tf_iterator_for_stmtr.   r"   r    register_overridesr@   q   sI    $$  "3   ))  ,"D"Dr"   )__doc__r'   numpyr   %tensorflow.python.autograph.operatorsr   r   tensorflow.python.data.opsr   tensorflow.python.frameworkr   r   tensorflow.python.opsr   tensorflow.python.utilr	   r!   r*   r1   r9   r@   r.   r"   r    <module>rH      sE    3   > = 3 9 3 & '#L> )4(?(? r"   