
    AVh                        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m Z m!Z! ddl"m#Z#  ed Z$dg dfde#e!e$f   de%de#e!e$f   fdZ&  ed       ejN                  e&            Z(de#e!e$f   de%de#e!e$f   fdZ) ed Z*dg dfde#e!e*f   de%de#e!e*f   fdZ+  ed       ejN                  e+            Z,de#e!e*f   de%de#e!e*f   fdZ- ed Z.ddg ddfde#e!e.f   de%de%d e/de#e!e.f   f
d!Z0  ed"       ejN                  e0            Z1de#e!e.f   de%de%d e/de#e!e.f   f
d#Z2 ed$ Z3ddd%d%g d&ddfde#e!e3f   d'e%d(e%d)e4d*e4d+e4d,e%de#e!e3f   fd-Z5  ed.       ejN                  e5            Z6de#e!e3f   d'e%d(e%d)e4d*e4d+e4d,e%de#e!e3f   fd/Z7 ed0 Z8ddddd%g ddfde#e!e8f   de%de%d1e%d2e/d3e4d e/de#e!e8f   fd4Z9  ed5       ejN                  e9            Z:de#e!e8f   de%de%d1e%d2e/d3e4d e/de#e!e8f   fd6Z; ed7 Z<ddg ddfde#e!e<f   de%de%d e/de#e!ejz                  f   f
d8Z>  ed9       ejN                  e>            Z?de#e!e<f   de%de%d e/de#e!ejz                  f   f
d:Z@ ed; ZAddg  eBd<       eBd=      dddfde#e!eAf   de%de%d>eBd?eBd@e/d e/de#e!ej                  f   fdAZD  edB       ejN                  eD            ZEde#e!eAf   de%de%d>eBd?eBd@e/d e/de#e!ej                  f   fdCZF edDdEdF      ZG edG ZHej                  d%d%dfde#e!eHf   dHeGd*e4dIe4de#e!eGf   f
dJZJ  edK       ejN                  eJ            ZKde#e!eHf   dHeGd*e4dIe4de#e!eGf   f
dLZLy)MzUPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
    N)
pywrap_tfe)context)core)execute)dtypes)annotation_types)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_export)TypeVarListAny)	Annotated) 	TV_Copy_T_atypes.BFloat16_atypes.Bool_atypes.Complex128_atypes.Complex64_atypes.Float16_atypes.Float32_atypes.Float64_atypes.Float8e4m3b11fnuz_atypes.Float8e4m3fn_atypes.Float8e4m3fnuz_atypes.Float8e5m2_atypes.Float8e5m2fnuz_atypes.Half_atypes.Int16_atypes.Int32_atypes.Int4_atypes.Int64_atypes.Int8_atypes.QInt16_atypes.QInt32_atypes.QInt8_atypes.QUInt16_atypes.QUInt8_atypes.Resource_atypes.String_atypes.UInt16_atypes.UInt32_atypes.UInt4_atypes.UInt64_atypes.UInt8_atypes.Variant inputtensor_namereturnc           
         t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d|| d|d|      }|S |d}t        j                  |d      }|g }t        |t         t"        f      st%        d|z        |D cg c]  }t        j                  |d       }}t'        j(                  d| |||      \  }	}	}
}|dd }t        j*                         rYd	|
j-                  d	      d|
j/                  d      d|
j/                  d      f}|
j0                  }t        j2                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||||      S # t        j                  $ r Y mw xY wc c}w )
aX  Copy a tensor from CPU-to-CPU or GPU-to-GPU.

  Performs CPU-to-CPU or GPU-to-GPU deep-copying of tensor, depending on the
  device on which the tensor is allocated.
  N.B.: If the all downstream attached debug ops are disabled given the current
  gRPC gating status, the output will simply forward the input tensor without
  deep-copying. See the documentation of Debug* ops for more details.

  Unlike the CopyHost Op, this op does not have HostMemory constraint on its
  input or output.

  Args:
    input: A `Tensor`. Input tensor.
    tensor_name: An optional `string`. Defaults to `""`.
      The name of the input tensor.
    debug_ops_spec: An optional list of `strings`. Defaults to `[]`.
      A list of debug op spec (op, url, gated_grpc) for attached debug
      ops. Each element of the list has the format
      <debug_op>;<grpc_url>;<gated_grpc>, wherein gated_grpc is boolean represented
      as 0/1. E.g., "DebugIdentity;grpc://foo:3333;1",
      "DebugIdentity;file:///tmp/tfdbg_1;0".
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  Copyr5   debug_ops_specNr5   r9   namectxr3   AExpected list for 'debug_ops_spec' argument to 'copy' Op, not %r.r4   r5   r9   r;   T)_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackExceptioncopy_eager_fallback_SymbolicException_executemake_str
isinstancelisttuple	TypeError_op_def_library_apply_op_helpermust_record_gradient_get_attr_typeget_attrinputsrecord_gradientr4   r5   r9   r;   _ctxtld_resulte_s__op_outputs_attrs_inputs_flats                 S/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_debug_ops.pycopyrd      s   6 
			0h..0$#\\11fdE=+.*g n K!!+}=+N	NT5M	2
	-	./ / GUUH%%b*:;U.U'88e-D:!QX QK'""$3%%c*Mll=)+;ll+,.F ::Lfg/('	.C && -
##At,,## 
 
[  ## 
 V6    E $GF!-FF! F!%F5 5GGzraw_ops.Copyc                    |d}t        j                  |d      }|g }t        |t        t        f      st        d|z        |D cg c]  }t        j                  |d       }}t        j                  | g|g       \  }\  } | g}d|d|d|f}t        j                  dd||||      }	t        j                         rt        j                  d	|||	       |	\  }	|	S c c}w )
Nr3   r5   r=   r9   r?   s   Copy   rV   attrsr<   r;   r8   
rK   rL   rM   rN   rO   rP   args_to_matching_eagerr   rS   rW   
r4   r5   r9   r;   r<   r]   _attr_Trb   ra   r[   s
             rc   rI   rI   d   s   K!!+}=+N	NT5M	2
	-	./ / GUUH%%b*:;U.U55ugsBG'8E,-6F&WaF!$41'""$fg/('	. V   C) TV_CopyHost_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   c           
         t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d|| d|d|      }|S |d}t        j                  |d      }|g }t        |t         t"        f      st%        d|z        |D cg c]  }t        j                  |d       }}t'        j(                  d| |||      \  }	}	}
}|dd }t        j*                         rYd	|
j-                  d	      d|
j/                  d      d|
j/                  d      f}|
j0                  }t        j2                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||||      S # t        j                  $ r Y mw xY wc c}w )
a  Copy a tensor to host.

  Performs CPU-to-CPU deep-copying of tensor.
  N.B.: If the all downstream attached debug ops are disabled given the current
  gRPC gating status, the output will simply forward the input tensor without
  deep-copying. See the documentation of Debug* ops for more details.

  Unlike the Copy Op, this op has HostMemory constraint on its input or output.

  Args:
    input: A `Tensor`. Input tensor.
    tensor_name: An optional `string`. Defaults to `""`.
      The name of the input tensor.
    debug_ops_spec: An optional list of `strings`. Defaults to `[]`.
      A list of debug op spec (op, url, gated_grpc) for attached debug
      ops. Each element of the list has the format
      <debug_op>;<grpc_url>;<gated_grpc>, wherein gated_grpc is boolean represented
      as 0/1. E.g., "DebugIdentity;grpc://foo:3333;1",
      "DebugIdentity;file:///tmp/tfdbg_1;0".
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  CopyHostr5   r9   Nr:   r3   FExpected list for 'debug_ops_spec' argument to 'copy_host' Op, not %r.r>   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH   copy_host_eager_fallbackrJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   s                 rc   	copy_hostrt   ~   s   2 
			0h..0$#\\11j$}k.*g n K!!+}=+N	NT5M	2
	"$2	34 4 GUUH%%b*:;U.U'88%[#1>!QX QK'""$3%%c*Mll=)+;ll+,.F ::LL&'3('	.C && -
##At,,## 
%
[  ## 
 Vre   zraw_ops.CopyHostc                    |d}t        j                  |d      }|g }t        |t        t        f      st        d|z        |D cg c]  }t        j                  |d       }}t        j                  | g|g       \  }\  } | g}d|d|d|f}t        j                  dd||||      }	t        j                         rt        j                  d	|||	       |	\  }	|	S c c}w )
Nr3   r5   rr   r9   r?   s   CopyHostrg   rh   rq   rj   rl   s
             rc   rs   rs      s   K!!+}=+N	NT5M	2
	"$2	34 4 GUUH%%b*:;U.U55ugsBG'8E,-6F&[!L#)s?'""$L&'3('	. Vrn   ) TV_DebugIdentity_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   Fdevice_name
gated_grpcc                 d   t         j                   xs t        j                         }|j                  }|j                  r#	 t	        j
                  |d|| d|d|d|d|      }|S |d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t         t"        f      st%        d	|z        |D 
cg c]  }
t        j                  |
d       }}
|d
}t        j&                  |d      }t)        j*                  d| |||||      \  }}}}|dd }t        j,                         r{d|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j3                  d      f
}|j4                  }t        j6                  d|||       |\  }|S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY wc c}
w )a  Provides an identity mapping of the non-Ref type input tensor for debugging.

  Provides an identity mapping of the non-Ref type input tensor for debugging.

  Args:
    input: A `Tensor`. Input tensor, non-Reference type
    device_name: An optional `string`. Defaults to `""`.
      Name of the device on which the tensor resides.
    tensor_name: An optional `string`. Defaults to `""`.
      Name of the input tensor.
    debug_urls: An optional list of `strings`. Defaults to `[]`.
      List of URLs to debug targets, e.g.,
        file:///foo/tfdbg_dump, grpc:://localhost:11011
    gated_grpc: An optional `bool`. Defaults to `False`.
      Whether this op will be gated. If any of the debug_urls of this
        debug node is of the grpc:// scheme, when the value of this attribute is set
        to True, the data will not actually be sent via the grpc stream unless this
        debug op has been enabled at the debug_url. If all of the debug_urls of this
        debug node are of the grpc:// scheme and the debug op is enabled at none of
        them, the output will be an empty Tensor.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  DebugIdentityrw   r5   
debug_urlsrx   Nrw   r5   r{   rx   r;   r<   r3   GExpected list for 'debug_urls' argument to 'debug_identity' Op, not %r.Fr4   rw   r5   r{   rx   r;   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH   debug_identity_eager_fallbackrJ   rK   rL   rM   rN   rO   rP   	make_boolrQ   rR   rS   rT   rU   _get_attr_boolrV   rW   r4   rw   r5   r{   rx   r;   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   s                   rc   debug_identityr      sU   4 
			0h..0$#\\	11otUM;{L*lg n K!!+}=+K!!+}=+J	Ju	.
	')3	45 5 ?II!!"l3I*IJ!!*l;*'88u+%0Z$.T;!QX QK'""$3%%c*Mll=)=ll=)<ll<(,  .	0F
 ::Lvw8('	.U && -
##At,,## 
*
[kJTtM M ## 
 J6    !F6 H-6G=	G$$G=<G=H H*)H*zraw_ops.DebugIdentityc           
      0   |d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t        t        f      st        d|z        |D cg c]  }t        j                  |d       }}|d}t        j                  |d      }t        j                  | g|g       \  }\  } | g}	d|d|d|d|d|f
}
t        j                  d	d
|	|
||      }t        j                         rt        j                  d|	|
|       |\  }|S c c}w )Nr3   rw   r5   r}   r{   Frx   r?   s   DebugIdentityrg   rh   rz   rK   rL   rM   rN   rO   rP   r   rk   r   rS   rW   r4   rw   r5   r{   rx   r;   r<   r]   rm   rb   ra   r[   s               rc   r   r   1  sD   K!!+}=+K!!+}=+J	Ju	.
	')3	45 5 ?II!!"l3I*IJ!!*l;*55ugsBG'8E,-m|ZzC&-q#)s?'""$vw8('	. J   !D) TV_DebugIdentityV2_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2     tfdbg_context_idop_nameoutput_slottensor_debug_modecircular_buffer_sizetfdbg_run_idc	                 ~   t         j                   xs t        j                         }	|	j                  }
|
j                  r)	 t	        j
                  |	d|| d|d|d|d|d|d|d|      }|S |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|g }t!        |t"        t$        f      st'        d|z        |D cg c]  }t        j                  |d       }}|d}t        j                  |d      }|d}t        j                  |d      }t)        j*                  d| ||||||||
      \  }}}}|d	d	 }t        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j3                  d      d|j3                  d      d|j1                  d      d|j3                  d      d|j1                  d      f}|j4                  }t        j6                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d	}~nd	}~wt        j                  $ r Y nw xY w	 t        | |||||||||	

      S # t        j                  $ r Y Nw xY wc c}w )a  Debug Identity V2 Op.

  Provides an identity mapping from input to output, while writing the content of
  the input tensor by calling DebugEventsWriter.

  The semantics of the input tensor depends on tensor_debug_mode. In typical
  usage, the input tensor comes directly from the user computation only when
  graph_debug_mode is FULL_TENSOR (see protobuf/debug_event.proto for a
  list of all the possible values of graph_debug_mode). For the other debug modes,
  the input tensor should be produced by an additional op or subgraph that
  computes summary information about one or more tensors.

  Args:
    input: A `Tensor`. Input tensor, non-Reference type
    tfdbg_context_id: An optional `string`. Defaults to `""`.
      A tfdbg-generated ID for the context that the op belongs to,
        e.g., a concrete compiled tf.function.
    op_name: An optional `string`. Defaults to `""`.
      Optional. Name of the op that the debug op is concerned with.
        Used only for single-tensor trace.
    output_slot: An optional `int`. Defaults to `-1`.
      Optional. Output slot index of the tensor that the debug op
        is concerned with. Used only for single-tensor trace.
    tensor_debug_mode: An optional `int`. Defaults to `-1`.
      TensorDebugMode enum value. See debug_event.proto for details.
    debug_urls: An optional list of `strings`. Defaults to `[]`.
      List of URLs to debug targets, e.g., file:///foo/tfdbg_dump.
    circular_buffer_size: An optional `int`. Defaults to `1000`.
    tfdbg_run_id: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  DebugIdentityV2r   r   r   r   r{   r   r   N)	r   r   r   r   r{   r   r   r;   r<   r3   r   JExpected list for 'debug_urls' argument to 'debug_identity_v2' Op, not %r.r   )	r4   r   r   r   r   r{   r   r   r;   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH    debug_identity_v2_eager_fallbackrJ   rK   rL   make_intrM   rN   rO   rP   rQ   rR   rS   rT   rU   _get_attr_intrV   rW   )r4   r   r   r   r   r{   r   r   r;   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   s                      rc   debug_identity_v2r   Q  s   F 
			0h..0$#\\11u.@)Wm[.j 4ng n &&'79KL_Ggy1'K!!+}=+''(9;NOJ	Ju	.
	*,6	78 8 ?II!!"l3I*I!!**+?AWXL""<@,'889I#*->&00D(44A!QX QK'""$3%%c*,>ll-.	ll9%}.0C 34lll<(*@ 67ll>*,F ::L<:('	.w && -
##At,,## 
-
"2G!5F6J#$D	: :
 ## 
* Js6    'I  <J: JI..JJJ   J76J7zraw_ops.DebugIdentityV2c
                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t        t
        f      st        d|z        |D 
cg c]  }
t        j                  |
d       }}
|d	}t        j                  |d
      }|d}t        j                  |d      }t        j                  | g|	g       \  }\  } | g}d|d|d|d|d|d|d
|d|f}t        j                  dd|||	|      }t        j                         rt        j                  d|||       |\  }|S c c}
w )Nr3   r   r   r   r   r   r   r{   r   r   r   r?   s   DebugIdentityV2rg   rh   r   )rK   rL   r   rM   rN   rO   rP   rk   r   rS   rW   )r4   r   r   r   r   r{   r   r   r;   r<   r]   rm   rb   ra   r[   s                  rc   r   r     s   &&'79KL_Ggy1'K!!+}=+''(9;NOJ	Ju	.
	*,6	78 8 ?II!!"l3I*I!!**+?AWXL""<@,55ugsBG'8E,,.>		=+':<M
24H, & /<#)s?'""$<:('	.' Js   E') TV_DebugIdentityV3_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   
io_of_nodeis_inputio_indexc	                 ~   t         j                   xs t        j                         }	|	j                  }
|
j                  r)	 t	        j
                  |	d|| d|d|d|d|d|d|d|      }|S |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                   |d      }|g }t#        |t$        t&        f      st)        d|z        |D cg c]  }t        j                  |d       }}|d}t        j                  |d      }t+        j,                  d| ||||||||
      \  }}}}|d	d	 }t        j.                         rd|j1                  d      d|j3                  d      d|j3                  d      d|j3                  d      d|j5                  d      d|j7                  d      d|j3                  d      d|j5                  d      f}|j8                  }t        j:                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d	}~nd	}~wt        j                  $ r Y nw xY w	 t        | |||||||||	

      S # t        j                  $ r Y Nw xY wc c}w )a,  Provides an identity mapping of the non-Ref type input tensor for debugging.

  Provides an identity mapping of the non-Ref type input tensor for debugging.

  Args:
    input: A `Tensor`. Input tensor, non-Reference type
    device_name: An optional `string`. Defaults to `""`.
      Name of the device on which the tensor resides.
    tensor_name: An optional `string`. Defaults to `""`.
      Name of the input tensor.
    io_of_node: An optional `string`. Defaults to `""`.
      Name of the node of which the tensor is an input or output.
    is_input: An optional `bool`. Defaults to `False`.
      If true, the tensor is an input of the node; otherwise the output.
    io_index: An optional `int`. Defaults to `-1`.
      The index of which the tensor is an input or output of the node.
    debug_urls: An optional list of `strings`. Defaults to `[]`.
      List of URLs to debug targets, e.g.,
        file:///foo/tfdbg_dump, grpc:://localhost:11011
    gated_grpc: An optional `bool`. Defaults to `False`.
      Whether this op will be gated. If any of the debug_urls of this
        debug node is of the grpc:// scheme, when the value of this attribute is set
        to True, the data will not actually be sent via the grpc stream unless this
        debug op has been enabled at the debug_url. If all of the debug_urls of this
        debug node are of the grpc:// scheme and the debug op is enabled at none of
        them, the output will be an empty Tensor.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  DebugIdentityV3rw   r5   r   r   r   r{   rx   N)	rw   r5   r   r   r   r{   rx   r;   r<   r3   Fr   JExpected list for 'debug_urls' argument to 'debug_identity_v3' Op, not %r.)	r4   rw   r5   r   r   r   r{   rx   r;   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH    debug_identity_v3_eager_fallbackrJ   rK   rL   r   r   rM   rN   rO   rP   rQ   rR   rS   rT   rU   r   r   rV   rW   )r4   rw   r5   r   r   r   r{   rx   r;   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   s                      rc   debug_identity_v3r     s   @ 
			0h..0$#\\
11um[{L*j*hjj	"g
 n K!!+}=+K!!+}=+J  \:*H*5(Hx4(J	Ju	.
	*,6	78 8 ?II!!"l3I*IJ!!*l;*'88K'2z$,x&0Z $&!QX QK'""$3%%c*Mll=)=ll=)<ll<(*  ,j
+\ll<(,  .0F ::L<:('	.s && -
##At,,## 
-
[k(XJTtM M ## 
0 Js6    'I  J: JI..JJJ   J76J7zraw_ops.DebugIdentityV3c
                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|g }t	        |t
        t        f      st        d	|z        |D 
cg c]  }
t        j                  |
d
       }}
|d}t        j                  |d      }t        j                  | g|	g       \  }\  } | g}d|d|d|d|d|d|d
|d|f}t        j                  dd|||	|      }t        j                         rt        j                  d|||       |\  }|S c c}
w )Nr3   rw   r5   r   Fr   r   r   r   r{   rx   r?   s   DebugIdentityV3rg   rh   r   )rK   rL   r   r   rM   rN   rO   rP   rk   r   rS   rW   )r4   rw   r5   r   r   r   r{   rx   r;   r<   r]   rm   rb   ra   r[   s                  rc   r   r   R  s   K!!+}=+K!!+}=+J  \:*H*5(Hx4(J	Ju	.
	*,6	78 8 ?II!!"l3I*IJ!!*l;*55ugsBG'8E,-m|ZXz
L*lJ@& /<#)s?'""$<:('	. Js   /E') TV_DebugNanCount_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   c                 d   t         j                   xs t        j                         }|j                  }|j                  r#	 t	        j
                  |d|| d|d|d|d|      }|S |d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t         t"        f      st%        d	|z        |D 
cg c]  }
t        j                  |
d       }}
|d
}t        j&                  |d      }t)        j*                  d| |||||      \  }}}}|dd }t        j,                         r{d|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j3                  d      f
}|j4                  }t        j6                  d|||       |\  }|S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY wc c}
w )a3  Debug NaN Value Counter Op.

  Counts number of NaNs in the input tensor, for debugging.

  Args:
    input: A `Tensor`. Input tensor, non-Reference type.
    device_name: An optional `string`. Defaults to `""`.
    tensor_name: An optional `string`. Defaults to `""`.
      Name of the input tensor.
    debug_urls: An optional list of `strings`. Defaults to `[]`.
      List of URLs to debug targets, e.g.,
        file:///foo/tfdbg_dump, grpc:://localhost:11011.
    gated_grpc: An optional `bool`. Defaults to `False`.
       Whether this op will be gated. If any of the debug_urls of this
        debug node is of the grpc:// scheme, when the value of this attribute is set
        to True, the data will not actually be sent via the grpc stream unless this
        debug op has been enabled at the debug_url. If all of the debug_urls of this
        debug node are of the grpc:// scheme and the debug op is enabled at none of
        them, the output will be an empty Tensor.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int64`.
  DebugNanCountrw   r5   r{   rx   Nr|   r3   HExpected list for 'debug_urls' argument to 'debug_nan_count' Op, not %r.Fr~   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH   debug_nan_count_eager_fallbackrJ   rK   rL   rM   rN   rO   rP   r   rQ   rR   rS   rT   rU   r   rV   rW   r   s                   rc   debug_nan_countr   |  sU   2 
			0h..0$#\\	11otUM;{L*lg n K!!+}=+K!!+}=+J	Ju	.
	(*4	56 6 ?II!!"l3I*IJ!!*l;*'88u+%0Z$.T;!QX QK'""$3%%c*Mll=)=ll=)<ll<(,  .	0F
 ::Lvw8('	.U && -
##At,,## 
+
[kJTtM M ## 
 Jr   zraw_ops.DebugNanCountc           
      0   |d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t        t        f      st        d|z        |D cg c]  }t        j                  |d       }}|d}t        j                  |d      }t        j                  | g|g       \  }\  } | g}	d|d|d|d|d|f
}
t        j                  d	d
|	|
||      }t        j                         rt        j                  d|	|
|       |\  }|S c c}w )Nr3   rw   r5   r   r{   Frx   r?   s   DebugNanCountrg   rh   r   r   r   s               rc   r   r     sD   K!!+}=+K!!+}=+J	Ju	.
	(*4	56 6 ?II!!"l3I*IJ!!*l;*55ugsBG'8E,-m|ZzC&-q#)s?'""$vw8('	. Jr   ) TV_DebugNumericSummary_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   -infinflower_boundupper_boundmute_if_healthyc	                    t         j                   xs t        j                         }	|	j                  }
|
j                  r)	 t	        j
                  |	d|| d|d|d|d|d|d|d|      }|S |d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t         t"        f      st%        d|z        |D cg c]  }t        j                  |d       }}|t'        d      }t        j(                  |d      }|t'        d      }t        j(                  |d      }|d}t        j*                  |d      }|d}t        j*                  |d      }t-        j.                  d| ||||||||
      \  }}}}|d	d	 }t        j0                         rd|j3                  d      d|j5                  d      d|j5                  d      d|j5                  d      d|j5                  d      d|j5                  d      d|j7                  d      d|j7                  d      f}|j8                  }t        j:                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d	}~nd	}~wt        j                  $ r Y nw xY w	 t        | |||||||||	

      S # t        j                  $ r Y `w xY wc c}w )a  Debug Numeric Summary Op.

  Provide a basic summary of numeric value types, range and distribution.

  output: A double tensor of shape [14 + nDimensions], where nDimensions is the
    number of dimensions of the tensor's shape. The elements of output are:
    [0]: is initialized (1.0) or not (0.0).
    [1]: total number of elements
    [2]: NaN element count
    [3]: generalized -inf count: elements <= lower_bound. lower_bound is -inf by
      default.
    [4]: negative element count (excluding -inf), if lower_bound is the default
      -inf. Otherwise, this is the count of elements > lower_bound and < 0.
    [5]: zero element count
    [6]: positive element count (excluding +inf), if upper_bound is the default
      +inf. Otherwise, this is the count of elements < upper_bound and > 0.
    [7]: generalized +inf count, elements >= upper_bound. upper_bound is +inf by
      default.
  Output elements [1:8] are all zero, if the tensor is uninitialized.
    [8]: minimum of all non-inf and non-NaN elements.
         If uninitialized or no such element exists: +inf.
    [9]: maximum of all non-inf and non-NaN elements.
         If uninitialized or no such element exists: -inf.
    [10]: mean of all non-inf and non-NaN elements.
          If uninitialized or no such element exists: NaN.
    [11]: variance of all non-inf and non-NaN elements.
          If uninitialized or no such element exists: NaN.
    [12]: Data type of the tensor encoded as an enum integer. See the DataType
          proto for more details.
    [13]: Number of dimensions of the tensor (ndims).
    [14+]: Sizes of the dimensions.

  Args:
    input: A `Tensor`. Input tensor, non-Reference type.
    device_name: An optional `string`. Defaults to `""`.
    tensor_name: An optional `string`. Defaults to `""`.
      Name of the input tensor.
    debug_urls: An optional list of `strings`. Defaults to `[]`.
      List of URLs to debug targets, e.g.,
        file:///foo/tfdbg_dump, grpc:://localhost:11011.
    lower_bound: An optional `float`. Defaults to `float('-inf')`.
      (float) The lower bound <= which values will be included in the
        generalized -inf count. Default: -inf.
    upper_bound: An optional `float`. Defaults to `float('inf')`.
      (float) The upper bound >= which values will be included in the
        generalized +inf count. Default: +inf.
    mute_if_healthy: An optional `bool`. Defaults to `False`.
      (bool) Do not send data to the debug URLs unless at least one
        of elements [2], [3] and [7] (i.e., the nan count and the generalized -inf and
        inf counts) is non-zero.
    gated_grpc: An optional `bool`. Defaults to `False`.
      Whether this op will be gated. If any of the debug_urls of this
        debug node is of the grpc:// scheme, when the value of this attribute is set
        to True, the data will not actually be sent via the grpc stream unless this
        debug op has been enabled at the debug_url. If all of the debug_urls of this
        debug node are of the grpc:// scheme and the debug op is enabled at none of
        them, the output will be an empty Tensor.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `float64`.
  DebugNumericSummaryrw   r5   r{   r   r   r   rx   N)	rw   r5   r{   r   r   r   rx   r;   r<   r3   NExpected list for 'debug_urls' argument to 'debug_numeric_summary' Op, not %r.r   r   F)	r4   rw   r5   r{   r   r   r   rx   r;   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH   $debug_numeric_summary_eager_fallbackrJ   rK   rL   rM   rN   rO   rP   float
make_floatr   rQ   rR   rS   rT   rU   r   rV   rW   )r4   rw   r5   r{   r   r   r   rx   r;   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   s                      rc   debug_numeric_summaryr     s   ~ 
			0h..0$#\\
11#T5-{L*m]K1Bz	3g
 n K!!+}=+K!!+}=+J	Ju	.
	.0:	;< < ?II!!"l3I*I-K##K?+,K##K?+O&&8IJ/J!!*l;*'88U+6:+6+6/>*44A!QX QK'""$3%%c*Mll=)=ll=)<ll<(-ll=)=ll=)+<  !23\  .0F ::L|VW>('	.w && -
##At,,## 
1
[k[!?d	6 6
 ## 
 Js6    'I KJ%J  JJJ2 2K	K	zraw_ops.DebugNumericSummaryc
                    |d}t        j                  |d      }|d}t        j                  |d      }|g }t        |t        t        f      st        d|z        |D 
cg c]  }
t        j                  |
d       }}
|t        d      }t        j                  |d      }|t        d      }t        j                  |d	      }|d
}t        j                  |d      }|d
}t        j                  |d      }t        j                  | g|	g       \  }\  } | g}d|d|d|d|d|d	|d|d|f}t        j                  dd|||	|      }t        j                         rt        j                  d|||       |\  }|S c c}
w )Nr3   rw   r5   r   r{   r   r   r   r   Fr   rx   r?   s   DebugNumericSummaryrg   rh   r   )rK   rL   rM   rN   rO   rP   r   r   r   rk   r   rS   rW   )r4   rw   r5   r{   r   r   r   rx   r;   r<   r]   rm   rb   ra   r[   s                  rc   r   r   v  s   K!!+}=+K!!+}=+J	Ju	.
	.0:	;< < ?II!!"l3I*I-K##K?+,K##K?+O&&8IJ/J!!*l;*55ugsBG'8E,-m|Z/
& 3Q|#)s?'""$|VW>('	.3 Js   !E9%TV_DebugNumericSummaryV2_output_dtyper   r   ) TV_DebugNumericSummaryV2_Tr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   output_dtype	tensor_idc                    t         j                   xs t        j                         }|j                  }|j                  r!	 t	        j
                  |d|| d|d|d|
      }|S |t        j                  }t        j                   |d      }|d}t        j"                  |d      }|d}t        j"                  |d      }t%        j&                  d| ||||      \  }	}	}
}|dd }t        j(                         rjd|
j+                  d      d	|
j+                  d	      d|
j-                  d      d|
j-                  d      f}|
j.                  }t        j0                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||||      S # t        j                  $ r Y ww xY w)
a  Debug Numeric Summary V2 Op.

  Computes a numeric summary of the input tensor. The shape of the output
  depends on the tensor_debug_mode attribute.
  This op is used internally by TensorFlow Debugger (tfdbg) v2.

  Args:
    input: A `Tensor`. Input tensor, to be summarized by the op.
    output_dtype: An optional `tf.DType` from: `tf.float32, tf.float64`. Defaults to `tf.float32`.
      Optional. The type of the output. Can be float32 or float64 (default: float32).
    tensor_debug_mode: An optional `int`. Defaults to `-1`.
      Tensor debug mode: the mode in which the input tensor is summarized
        by the op. See the TensorDebugMode enum in
        tensorflow/core/protobuf/debug_event.proto for details.

      Supported values:
        2 (CURT_HEALTH): Output a float32/64 tensor of shape [2]. The 1st
        element is the tensor_id, if provided, and -1 otherwise. The 2nd
        element is a bit which is set to 1 if the input tensor has an
        infinity or nan value, or zero otherwise.

        3 (CONCISE_HEALTH): Output a float32/64 tensor of shape [5]. The 1st
        element is the tensor_id, if provided, and -1 otherwise. The
        remaining four slots are the total number of elements, -infs,
        +infs, and nans in the input tensor respectively.

        4 (FULL_HEALTH): Output a float32/64 tensor of shape [11]. The 1st
        element is the tensor_id, if provided, and -1 otherwise. The 2nd
        element is the device_id, if provided, and -1 otherwise. The 3rd
        element holds the datatype value of the input tensor as according
        to the enumerated type in tensorflow/core/framework/types.proto.
        The remaining elements hold the total number of elements, -infs,
        +infs, nans, negative finite numbers, zeros, and positive finite
        numbers in the input tensor respectively.

        5 (SHAPE): Output a float32/64 tensor of shape [10]. The 1st
        element is the tensor_id, if provided, and -1 otherwise. The 2nd
        element holds the datatype value of the input tensor as according
        to the enumerated type in tensorflow/core/framework/types.proto.
        The 3rd element holds the rank of the tensor. The 4th element holds
        the number of elements within the tensor. Finally the remaining 6
        elements hold the shape of the tensor. If the rank of the tensor
        is lower than 6, the shape is right padded with zeros. If the rank
        is greater than 6, the head of the shape is truncated.

        6 (FULL_NUMERICS): Output a float32/64 tensor of shape [22]. The 1st
        element is the tensor_id, if provided, and -1 otherwise. The 2nd
        element is the device_id, if provided, and -1 otherwise. The 3rd
        element holds the datatype value of the input tensor as according
        to the enumerated type in tensorflow/core/framework/types.proto.
        The 4th element holds the rank of the tensor. The 5th to 11th
        elements hold the shape of the tensor. If the rank of the tensor
        is lower than 6, the shape is right padded with zeros. If the rank
        is greater than 6, the head of the shape is truncated. The 12th to
        18th elements hold the number of elements, -infs, +infs, nans,
        denormal floats, negative finite numbers, zeros, and positive
        finite numbers in the input tensor respectively. The final four
        elements hold the min value, max value, mean, and variance of the
        input tensor.

        8 (REDUCE_INF_NAN_THREE_SLOTS): Output a float32/64 tensor of shape
        [3]. The 1st element is -inf if any elements of the input tensor
        is -inf, or zero otherwise. The 2nd element is +inf if any elements
        of the input tensor is +inf, or zero otherwise.  The 3rd element is
        nan if any element of the input tensor is nan, or zero otherwise.
    tensor_id: An optional `int`. Defaults to `-1`.
      Optional. An integer identifier for the tensor being summarized by this op.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `output_dtype`.
  DebugNumericSummaryV2r   r   r   N)r   r   r   r;   r<   r   )r4   r   r   r   r;   r?   )r@   r   rA   rB   r   rC   rD   rE   rF   rG   rH   'debug_numeric_summary_v2_eager_fallbackrJ   _dtypesfloat32rK   	make_typer   rQ   rR   rS   rT   r   rV   rW   )r4   r   r   r   r;   rY   rZ   r[   r\   r^   r_   r`   ra   rb   s                 rc   debug_numeric_summary_v2r     s   R 
			0h..0$#\\	11%tUN)+<kg n ??L##L.A,''(9;NOI	;7)'88u<3D+44A!QX QK'""$c00@#  %': 34k,.F ::Lvw@('	.G && -
##At,,## 
4
l-  ## 
s0    E% %F,8FF,+F,0G GGzraw_ops.DebugNumericSummaryV2c                    |t         j                  }t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t        j
                  | g|g       \  }\  } | g}d|d|d|d|f}t        j                  dd||||      }	t        j                         rt        j                  d	|||	       |	\  }	|	S )
Nr   r   r   r   r?   s   DebugNumericSummaryV2rg   rh   r   )	r   r   rK   r   r   rk   r   rS   rW   )
r4   r   r   r   r;   r<   rm   rb   ra   r[   s
             rc   r   r     s    ??L##L.A,''(9;NOI	;7)55ugsBG'8E,L#w8K[)-&5q#)s?'""$vw@('	.    )M__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r@   r   rD   r   rK   tensorflow.python.frameworkr   r   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   rF   r   rQ   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   	_dispatch tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   r   strrd   	to_raw_opr8   rI   ro   rt   rq   rs   rv   boolr   rz   r   r   intr   r   r   r   r   r   r   r   Int64r   r   r   r   r   Float64r   r   r   r   r   r   r   r   r    r   rc   <module>r      sI	  
  6 7 1 7 9 F K 3 I C 8 6 % % '  v		;=bW[ D	#y.) Ds D`ijmoxjx`y DL !y !56yi8 s jstw  zC  uC  kD 0   ~	DFWY`d BYsM12 B Birsv  yF  tF  jG BH )9'(	)BCIc=.@$A PS s|  ~A  CP  ~P  tQ 0   H
 NPbdqs  FK  RV M)C);$;< M# M^a M  AE M  [d  eh  j|  e|  [} M^ 3	12>4>>.3QR38J3J)K Z] lo   JN   ^g  hk  m  h  ^@ <   L
 XZhj|~  WY  fh  CG  Z\  cg iYs,@'@A iTW idg ix{ i  SV i  B i  VY i  lu  vy  {O  vO  lP iV 7)56~t~~FW7XY&Ic;O6O,P &dg &ru &  EH &  ]` &  DG &  WZ &  js  tw  yM  tM  jN &R   L
 SUgiz|  MR  ac  pr  DI  PT cYs,@'@A cs ccf cvy c  HL c  ]` c  C c  Yb  cf  h|  c|  Y} cJ 7)56~t~~FW7XY%Ic;O6O,P %_b %qt %  CF %  RV %  be %  C %  S\  ]`  bv  ]v  Sw %P   H
 OQcert  GL  SW L9S*<%<= L3 L_b L  BF L  \e  fi  kr  kx  kx  fx  \y L\ 3	12>4>>/3RS)C9K4K*L [^ mp   KO   _h  il  nu  n{  n{  i{  _| < #  T
 []oq  A  UZ  [a  Ub  v{  |A  vB  Y^  pu  |@ D30H+H!I DWZ Dkn D  OT D  pu D  TX D  ko D  EN  OR  T[  Tc  Tc  Oc  Ed DL ?i =>~t~~Nc?de &	#?W:W0X &gj &y| &  X] &  lq &  DH &  VZ &  js  tw  y@  yH  yH  tH  jI &R )00WYjl}(~ %$  X
  DK  DS  DS  km  }  FJ uIc3M.M$N u  ^C u  gj u  y| u  OX  Y\  ^C  YC  OD un C	"AB>4>>RjCkl 9SB\=\3]   nS   hk   x{   KT  UX  Z  U  K@ r   