
    AVhr                     -   d 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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lmZ ddlmZ ddlmZ ddlmZ ej@                  Z g Z!g Z"d Z#d)dZ$d*dZ%d Z& e$ejN                        e_'         e$ejP                        e_(         e$ejR                        e_)         e$ejT                        e_*         e$ejV                        e_+         e$ejX                        e_,         e$ejZ                        e_-         e$ej\                        e_.         e$ej^                        e_/         e$ej`                        e_0         e$ejb                        e_1         e$ejd                        e_2         e$ejf                        e_3         e$ejh                        e_4         e$ejj                        e_5         e$ejl                        e_6         e$ejn                        e_7         e$ejp                        e_8         e$ejr                        e_9         e$ejt                        e_:         e$ejv                        e_;         e$ejx                        e_<         e$ejz                        e_=         e$ej|                        e_>         e$ej~                        e_?         e$ej                        e_@         e$ej                        e_A         e$ej                        e_B         e$ej                        e_C         e$ej                        e_D         e$ej                        e_E         e$ej                        e_F         e$ej                        e_G         e$ej                        e_H         e$ej                        e_I         e$ej                        e_J         e$ej                        e_K         e$ej                        e_L         e$ej                        e_M         e$ej                        e_N         e$ej                        e_O         e$ej                        e_P         e$ej                        e_Q         e$e
j                        e
_R         e$e
j                        e
_S         e$e
j                        e
_T         e$e
j                        e
_U         e$ej                        e_V         e$ej                        e_W         e$ej                        e_X         e$ej                        e_Y         e$ej                        e_Z         e$ej                        e_[         e$ej                        e_\         e$ej                        e_]         e$ej                        e_^         e$ej                        e__         e$ej                        e_`         e$ej                        e_a         e$ej                        e_b         e$ej                        e_c         e$ej                        e_d         e$ej                        e_e         e$ej                        e_f         e$ej                        e_g         e$ej                        e_h         e$ej                        e_i         e$ej                        e_j         e$ej                        e_k         e$ej                        e_l         e$ej                        e_m         e$ej                        e_n         e$ej                        e_o         e$ej                        e_p         e$ej                        e_q         e$ej                        e_r         e$ej                        e_s         e$ej                        e_t         e$ej                        e_u         e$ej                        e_v         e$ej                        e_w         e$ej                        e_x         e$ej                        e_y         e$ej                        e_z         e$ej                        e_{         e$ej                        e_|         e$ej                        e_}         e$ej                        e_~         e$ej                        e_         e$ej                         e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej
                        e_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                        e
_         e$e
j                         e
_         e$e
j"                        e
_         e$e
j$                        e
_         e$e
j&                        e
_         e$e
j(                        e
_         e$e
j*                        e
_         e$e
j,                        e
_         e$e
j.                        e
_         e$e
j0                        e
_         e$ejN                        e_'         e$ej2                        e_         e$ejX                        e_,         e$ej4                        e_         e$ej6                        e_         e$ej8                        e_         e$ej:                        e_         e$ej<                        e_         e$ej>                        e_         e$ej@                        e_         e$ejj                        e_5         e$ej`                        e_0         e$ejB                        e_         e$ej                        e_A         e$ej                        e_B         e$ejD                        e_         e$ejn                        e_7         e$ejF                        e_         e$ej                        e_F         e$ejH                        e_         e$ejJ                        e_         e$ejt                        e_:         e$ej                        e_H         e$ejL                        e_         e$ejN                        e_         e$ej                        e_K         e$ej                        e_M         e$ej                        e_N         e$ejl                        e_6         e$ej                        e_P         e$ej                        e_Q         e$ejP                        e_         e$ejR                        e_         e$ejT                        e_         e$ej                        e_I         e$ejV                        e_         e$ejX                        e_         e$ej                        e_O         e$ejZ                        e_         e$ej\                        e_         e$ej^                        e_         e$ej
                        e_         e$ej`                        e_         e$ejb                        e_         e$ejd                        e_         e$ejf                        e_         e$ejh                        e_         e$ejj                        e_         e$ejl                        e_         e$ejn                        e_         e$ejp                        e_         e$ejr                        e_         e$ejt                        e_         e$ejv                        e_         e$ejx                        e_         e$ejz                        e_         e$ej|                        e_         e$ej                        e_         e$ej~                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ejV                        e_+         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_T         e$ej                        e_         e$ej                        e_         e$ejT                        e_*         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ejZ                        e_-         e$ej&                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej.                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_         e$ej                        e_R         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e$ej                  d      e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                        e_         e%ej                  d       e_         e%ej                  d       e_         e%ej                  d       e_         e%ej                  d       e_         e%ej                  d       e_         e%e j                  d!       e _         e%e j                  d!       e _         e%e j                  d!       e _         e$ej                        e_         e%ej                  d"d#$      e_        ej                  e_        ej                  e_        ej                  e_        ej                  e_        ej                  e_        ej                  ej                  _        ej                  ej                  _        ejN                  ej                  _        g d%Zej                  j                  D ]0  Zeev r eej                  e      Z eej                  ee       2  ej                  ej                          eej                  d&ejd                          eej                  d'ej                          eej                  d(ej                         y)+z!Support for WeakTensor in TF ops.    N)composite_tensor)constant_op)flexible_dtypes)ops)tensor)weak_tensor)	array_ops)clip_ops)gen_array_ops)gen_bitwise_ops)gen_math_ops)	image_ops)math_ops)nn_impl)nn_ops)resource_variable_ops)special_math_ops)np_array_ops)np_math_ops)
tf_logging)core)dispatch)tf_decoratorc                    t        | t        j                        r| j                         } t        | t        j
                        st        | t        j                        rt        j                  | ||      S t        j                  | ||      S )z$Converts/casts the input x to dtype.)dtypename)
isinstancer   
WeakTensor	to_tensorr   Tensorr   CompositeTensorr   castr   convert_to_tensor)xr   r   s      U/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/weak_tensor_ops.py_convert_or_castr&   6   sl     ;))*	A 4;;:		)	)$ ==%d33  %d;;    c                     t        j                         .t        j                  j	                               }t        |       fd}t        j                   |      }t        |       t        j                  |       |S )a  Infers input type and adds WeakTensor support to unary ops.

  This wrapper infers input type according to the auto dtype conversion
  semantics - Tensor and NumPy inputs as Tensor of corresponding dtype and
  WeakTensor and python inputs as WeakTensor of corresponding dtype. If the
  inferred input dtype is "weak" and the op doesn't specify a return dtype,
  returns WeakTensor.
  c                  :   t        j                         s | i |S  j                  | i |}|j                          |j                  }|	   }t        |t        j                        s|j                  dd        di |S 	 t        j                  |      \  }}t#        ||d      |	<   t%        j&                   di ||      S # t        $ rG t        j                  dj                   dj                   dt!        |       d        di |cY S w xY w)Nr   'The new dtype semantics do not support .(!). Falling back to old semantics.r$    )r    is_auto_dtype_conversion_enabledbindapply_defaults	argumentsr   r   r    getr   result_typeNotImplementedErrorloggingwarning
__module____name__typer&   r    convert_to_weak_tensor_or_tensor)
argskwargsbound_argumentsbound_kwargsr$   target_typeis_weakop	signature
x_arg_names
          r%   wrapperz-weak_tensor_unary_op_wrapper.<locals>.wrapperV   s.   //1   $innd5f5O""$",,LZ A 	1fmm$GT*6,
 ,88;k7  0;DL77
\G    oomm_Abkk]!DG9 5
 , s   C
 
ADD)inspectrC   iter
parameterskeysnextr   make_decorator0_update_weak_tensor_patched_ops_in_dispatch_dict_TF_UNARY_APISappend)rB   rD   	arg_namesrE   rC   s   ``  @r%   weak_tensor_unary_op_wrapperrP   H   su     #)Y))..01IiJ> ''G4' 37;  	.r'   c                 .    t        j                         t        j                  j	                               }t        |      t        |       fd}t        j                   |      }t        |       t        j                  |       |S )a(  Determines result promotion type and adds WeakTensor support to binary ops.

  This wrapper first infers dtype of any Tensor, WeakTensor, python/numpy
  inputs. Then, both inputs are promoted to the correct promotion result dtype.
  If the result promotion dtype is "weak", returns WeakTensor.
  c                     t        j                         s | i |S  	j                  | i |}|j                          |j                  }|   }|   }	 t        j                  ||      \  }}
dk(  rp||j                  k7  rIt        dj                   d|j                   d	| d
| d|j                   d| dj                   d      t        ||d      |<    di |S 
dk(  rot!        |t"        j$                        r|j'                         |<   |:d}||k7  r di |S t!        |t(        j*                        r7t        ||d      |<   n&||d<   n t        ||d      |<   t        ||d      |<   
dk(  rd}t#        j,                   di ||      S # t        $ rS t        j                  dj                   dj                   dt        |       dt        |       d	        di |cY S w xY w)Nr*   r+   r,   z, r-   variable_methodz%Variable dtype is immutable. Calling z of Variable (with dtype z) on z requires converting z to zF. This is disabled in the current promotion semantics. Please convert z manually before calling yconstantFr$   r   comparison-methodr.   )r   r/   r0   r1   r2   r   r4   r5   r6   r7   r8   r9   r:   r   	TypeErrorr&   r   r   r   r   r   r    r;   )r<   r=   r>   r?   r$   rT   r@   rA   rB   rC   special_handlingrD   
y_arg_names           r%   rE   z.weak_tensor_binary_op_wrapper.<locals>.wrapper   sS   //1   $innd5f5O""$",,LZ AZ A
 ,88A>k7 ,, 
	?} M33477)5 D&&'SQWWI 6GGHc J335;;-q	B C 	C "2![#!Fl:, 
Z	' 
A{--	.#$;;=Z  
! #l#
# a%%5ac%J,z
" +W!1![#!Fl:!1![#!Fl:..g77
\G a   oomm_Abkk]!DG9BtAwi @
 , s   F AG87G8)rF   rC   rG   rH   rI   rJ   r   rK   rL   _TF_BINARY_APISrN   )rB   rY   rX   rO   rE   rC   rD   s   ```  @@r%   weak_tensor_binary_op_wrapperr[      s     #)9'',,./)I*iJ? ?B ''G4' 37; !	.r'   c                 V    t         j                  }| j                  }||v r	||   || <   yy)a  Update dispatch dictionary to store WeakTensor patched op references.

  _TYPE_BASED_DISPATCH_SIGNATURES in dispatch.py stores mappings from op
  reference to all the dispatchers it's registered with. We need to update
  this dictionary to add a mapping from the patched-op reference to the
  signature dictionary the unpatched-op reference is mapped to. This ensures
  that dispatch can be reigstered and unregistered with monkey-patched ops.
  N)r   _TYPE_BASED_DISPATCH_SIGNATURES__wrapped__)
patched_opdispatch_dictunpatched_apis      r%   rL   rL      s6     ::-((-m# -m <M* $r'   r$   rV   )rX   rS   r   rU   )rY   rX   )
__invert____neg____abs__	__round___numpy_style_getitem_matmul)N)NN)__doc__rF   tensorflow.python.frameworkr   r   r   r   r   r   tensorflow.python.opsr	   r
   r   r   r   r   r   r   r   r   r   tensorflow.python.ops.numpy_opsr   r   tensorflow.python.platformr   r6   tensorflow.python.typesr   tensorflow.python.utilr   r   ResourceVariablerM   rZ   r&   rP   r[   rL   abssoftplussignrealimagangleroundsigmoidlog_sigmoidconjreciprocal_no_nanerfinvndtrierfcinvceilsqrtexprsqrtacosfloorinvertacoshasinasinhatanatanhcoscoshdigammaerferfcexpm1lgammaloglog1pneg
reciprocalrintsinsinhsquaretantanh
zeros_likezeros_like_v2	ones_likeones_like_v2check_numericsrelu6
leaky_relugelulog_softmaxlog_softmax_v2swishelureluselusoftsignrandom_brightnessstateless_random_brightnessadjust_brightnessadjust_gammaclip_by_valuedawsnexpintfresnel_cosfresnel_sinspence	bessel_i0
bessel_i0e	bessel_i1
bessel_i1e	bessel_k0
bessel_k0e	bessel_k1
bessel_k1e	bessel_j0	bessel_j1	bessel_y0	bessel_y1reduce_euclidean_normreduce_logsumexp
reduce_maxreduce_max_v1reduce_meanreduce_mean_v1
reduce_minreduce_min_v1reduce_prodreduce_prod_v1
reduce_std
reduce_sumreduce_sum_v1reduce_variancetracereshapedepth_to_spacedepth_to_space_v2expand_dimsexpand_dims_v2extract_image_patchesextract_image_patches_v2identitymatrix_diagmatrix_diag_partmatrix_transposespace_to_depthspace_to_depth_v2squeeze
squeeze_v2stop_gradienttensor_diag_part	transposetranspose_v2absolutearccosarcsinarcsinharctanarctanhbitwise_notcbrt	conjugatedeg2radexp2fabsfixnegativerad2degnanmeanlog2log10positivesincdiffsortaverageamaxaminaroundarangearray
asanyarrayasarrayascontiguousarraycopycumprodcumsumdiagdiagflatdiagonal
empty_likeflattenflipfliplrflipud	full_likemaxmeanminmoveaxisprodravelrepeatrot90stdsumswapaxestriuvandervaraddsubmultiplymultiply_no_nanmatmul
scalar_muldivide
div_no_nan_truediv_python3real_divtruncate_div	floor_divtruncate_mod	floor_mod_powmaximumminimumequalassign
assign_add
assign_subconvert_to_tensor_or_compositerU   realdivtruncatedivtruncatemodfloormodinvert_r   rb   rc   rd   unary_dunder_methodsr    OVERLOADABLE_OPERATORSoperatorgetattrtensor_opersetattr_enable_numpy_methods_getitemr.   r'   r%   <module>r>     s1   (  8 3 7 + . 3 + * / 1 . + * ) ( 7 2 8 7 < ( + / )99 <$4nUr=& ,HLL901B1BC ,X]];,X]];,X]];-hnn=-hnn=/0@0@A 3H4H4HI ,X]];9  /x?-hnn=/0@0@A ,X]];,X]];+HLL9-hnn=,X]];-hnn=5o6L6LM 1,2D2DE 01B1BC 1,2D2DE 01B1BC 1,2D2DE /0@0@A 01B1BC 3L4H4HI /0@0@A 01B1BC 1,2D2DE 2<3F3FG /0@0@A 1,2D2DE /0@0@A 6|7N7NO 01B1BC /0@0@A 01B1BC 2<3F3FG /0@0@A 01B1BC 3I4H4HI	 6y7N7NO	 293F3FG	 5i6L6LM	 ;     ,FLL901B1BC *6;;71&2D2DE 4V5J5JK ,W]];)&**5
*6;;7*6;;7.v?:	  )E)))	 % ;	  6i6L6LM	 5h6L6LM 56F6L6LM  67G7N7NO  ;       <      77G7N7NO  9   ;   :   ;   :   ;   :   ;   :   :   :   :  
 ">"""  9  383F3FG 5h6L6LM 3H4H4HI 6x7N7NO 283F3FG 5h6L6LM 3H4H4HI 6x7N7NO 283F3FG 283F3FG 5h6L6LM 7  .hnn=01B1BC	 7	  ;	  5Y5J5JK	 7	  #?###	  &B&&&	 " 2)2D2DE	 4Y5J5JK	 9	  :	  8	  ;	  11B1BC	 3I4H4HI	 6y7N7NO	 9	  393F3FG	 5i6L6LM	  /{?3K4H4HI 01B1BC 1+2D2DE 1+2D2DE 2;3F3FG 1+2D2DE 2;3F3FG 6{7N7NO /0@0@A /0@0@A /0@0@A 4[5J5JK .{?/0@0@A 2;3F3FG .{?/0@0@A 01B1BC /0@0@A .{?01B1BC .{?3K4H4HI 2;3F3FG 5k6L6LM .{?/0@0@A /0@0@A .{?/0@0@A 2;3F3FG /0@0@A 01B1BC 01B1BC 3K4H4HI /0@0@A 1+2D2DE /0@0@A /0@0@A 2;3F3FG 01B1BC 01B1BC 01B1BC 2<3F3FG 2<3F3FG 1,2D2DE 6|7N7NO 3L4H4HI !="""  11B1BC 3L4H4HI 2<3F3FG 01B1BC 4\5J5JK 4\5J5JK 6|7N7NO 7  4L4H4HI 01B1BC 2<3F3FG 2<3F3FG 5l6L6LM 01B1BC /0@0@A 01B1BC /0@0@A 4\5J5JK 5l6L6LM 01B1BC 1,2D2DE 01B1BC 3L4H4HI 2<3F3FG 1,2D2DE 1,2D2DE 3L4H4HI /0@0@A /0@0@A 4\5J5JK 5l6L6LM 01B1BC 2<3F3FG /0@0@A 6|7N7NO  -X\\:01A1AB 1(2C2CD 8  0@2;3E3EF 283F3FL /@3H4G4GH 9  6l6K6KL 9  7|7M7MN 9  7|7M7MN 1,2C2CD 4+>  5+>  3)<  1':  1':  8.?   <2C   <2C   &B&&&( " 5Wz   (( #00 !++ #00  **  %-$4$4   !!-!1!1   !)    < 44 9H%%x0+	+
 
 (K8	9 " ! !+"8"8 9 \-@-@ A  68M8M N 	;+=+= >r'   