
    AVhi                         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Zd Zd Zej$                  j'                  ej(                  e       ej*                  j'                  ej(                  e       y)zKAutograph specific overrides for objects covered by tensor_util.is_tf_type.    )py_builtins)dtypes)ops)tensor_util)	array_ops)	check_ops)
script_ops)sort_ops)control_flow_opsNc                 6   	
 g }i t              }t        t        t        j                              t        |      D ]*  }|   s	t        |      |<   |j                  |          , rpt        j                               

D ci c]  }|t        j                  |          c}	
D ]*  }	|   s	t        |      |<   |j                  |          , nd
 	
fd}t        j                  ||t        j                        S c c}w )a  Helper that wraps a callable to py_func.

  The helper passes tensor arguments through the py_func interface. Non-tensor
  arguments are allowed, and will be passed to f directly. Note that non-tensor
  arguments are captured by f will not update every time the wrapper is
  called (this is consistent with its argument list, which only includes
  the tensor arguments). In general, it's safest not to reuse this wrapper.

  Args:
    f: Callable
    args: Positional arguments for f, as list or tuple.
    kwargs: Keyword arguments for f, as dict with string keys. May be None.

  Returns:
    The return values of f converted to tensor.
  Raises:
    ValueError: if any of the arguments are incorrect.
   c                       t         fdt              D              }t        	      D ci c]  \  }}||   r |      n
|    }}} |i | yc c}}w )Nc              3   B   K   | ]  \  }}|   r|      n|  y wNr   ).0iaarg_is_tensortensor_argstensor_args_idxs      S/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/autograph_ops.py	<genexpr>z2wrap_py_func.<locals>.f_wrapper.<locals>.<genexpr>R   s3      Aq ,9+;OA&'Bs      )tuple	enumerate)r   f_argsr   kf_kwargsr   argsfkwarg_is_tensor
kwarg_keyskwargsr   s   `    r   	f_wrapperzwrap_py_func.<locals>.f_wrapperQ   sy     dO F j)Aq 	
oa.@;q)*fQiOH  vs   A)lenr   mapr   
is_tf_typerangeappendkeysr	   eager_py_funcr   int32)r    r   r#   r   n_argsr   r   r$   r   r!   r"   r   s   ```     @@@@r   wrap_py_funcr.      s   & +/ t9&K22D9:-= "aQ{+oaa!"" v{{}%JEOPq+00;;PO &		 -6!9%&
 J
 
 
	!	!)[&,,	GG) Qs    Dc                      |j                         D ci c]  \  }}|t        j                  us|| }}}d|vrd|d<   d }t        || |      S c c}}w )z/Overload of print_ as a py_func implementation.flushTc                  b    t        d | D              } t        d | D              } t        | i | y )Nc              3   j   K   | ]+  }t        j                  |      r|j                         n| - y wr   )r   r'   numpyr   vs     r   r   z;_tf_py_func_print.<locals>.print_wrapper.<locals>.<genexpr>k   s(     M1k44Q7Q>Ms   13c              3   b   K   | ]'  }t        |t              r|j                  d       n| ) yw)zutf-8N)
isinstancebytesdecoder4   s     r   r   z;_tf_py_func_print.<locals>.print_wrapper.<locals>.<genexpr>o   s'     PajE&:'"APs   -/)r   print)valsr#   s     r   print_wrapperz(_tf_py_func_print.<locals>.print_wrapperj   s1    MMMD P4PPD	46    )itemsr   UNSPECIFIEDr.   )objectsr#   r   r5   override_kwargsr<   s         r   _tf_py_func_printrB   `   sj     ||~q!+2I2I)Iad/  O#  $OG 
mWo	>>!s
   AAc                    |t         j                  u rd}nd}|t         j                  urt        j                  ||       }|j                  j
                  $|j                  j
                  dk7  rt        d      t        j                  t        j                  |dd      g      5  t        j                  ||      }t        j                  | |      cddd       S | j                  j
                  $| j                  j
                  dk7  rt        d      t        j                  t        j                  | dd      g      5  t        j                  | |      cddd       S # 1 sw Y   xY w# 1 sw Y   yxY w)z(Overload of sorted_ for Tensor iterable.	ASCENDING
DESCENDINGNr   z"sort only supports only 1D tensors)	direction)r   r?   parallel_opsvectorized_mapshaperank
ValueErrorr   control_dependenciesr   assert_rank_v2r
   argsortr   	gather_v2sort)iterablekeyreverserF   mappedorders         r   
_tf_sortedrV   u   sP   '''II'''((h7F||$):):a)?;<<		!	!  !E	G# 
 2 v;e  512 2 ^^$)<)<)A
9
::
xCE!  8 ==Y7	8 82 28 8s   %-E"E."E+.E7r   )__doc__%tensorflow.python.autograph.operatorsr   tensorflow.python.frameworkr   r   r   tensorflow.python.opsr   r   r	   r
   "tensorflow.python.ops.parallel_forr   rG   r.   rB   rV   print_registryregistertf_type_classessorted_registryr   r=   r   <module>r`      s{    R = . + 3 + + , * OAHH?*80    # #!2    $ $r=   