
    BVhP                     	   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d
lmZ  G d de      Z edg        G d de             Z edddg       ej,                  d       G d de                    Zej2                  Z ed      j5                  ed       ej8                  Z ed      j5                  ed       ej:                  Z ed      j5                  ed       ej<                  Z ed      j5                  ed       ej>                  Z ed      j5                  ed       ej@                  Z  ed      j5                  ed       ejB                  Z! ed       j5                  ed!       ejD                  Z" ed"      j5                  ed#       ejF                  Z# ed$      j5                  ed%       ejH                  Z$ ed&      j5                  ed'       ejJ                  Z% ed(      j5                  ed)       ejL                  Z& ed*      j5                  ed+       ejN                  Z' ed,      j5                  ed-       ejP                  Z( ed.      j5                  ed/       ejR                  Z) ed0      j5                  ed1       ejT                  Z* ed2      j5                  ed3       ejV                  Z+ ed4      j5                  ed5        ed6       G d7 d8e             Z, ed9       G d: d;e             Z- ed<       G d= d>e             Z. ed?       G d@ dAe             Z/ edB       G dC dDe             Z0 edE       G dF dGe             Z1 edH       G dI dJe             Z2 edK       G dL dMe             Z3 edN       G dO dPe             Z4 edQ       G dR dSe             Z5 edT       G dU dVe             Z6 edW       G dX dYe             Z7 edZ       G d[ d\e             Z8 ed]       G d^ d_e             Z9 ed`       G da dbe             Z: edc       G dd dee             Z;i ee,ee-ee.ee/e e0e!e1e"e2e#e3e$e4e%e5e&e6e'e7e(e8e)e9e*e:e+e;Z< ejz                  e<       e<j}                         D  ci c]  \  } }|| 
 c}} Z? edfg      dg        Z@ edhg      di        ZAdj ZB edkg       G dl dmeC             ZDyc c}} w )nz&Exception types for TensorFlow errors.    N)error_codes_pb2)_pywrap_py_exception_registry)pywrap_tf_session)
c_api_util)compat)deprecation)
tf_inspect)	tf_exportc                       e Zd Zy)InaccessibleTensorErrorN)__name__
__module____qualname__     W/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/framework/errors_impl.pyr   r      s    r   r   z%errors.OperatorNotAllowedInGraphError)v1c                       e Zd ZdZy)OperatorNotAllowedInGraphErrora  Raised when an unsupported operator is present in Graph execution.

  For example, using a `tf.Tensor` as a Python `bool` inside a Graph will
  raise `OperatorNotAllowedInGraphError`. Iterating over values inside a
  `tf.Tensor` is also not supported in Graph execution.

  Example:
  >>> @tf.function
  ... def iterate_over(t):
  ...   a,b,c = t
  ...   return a
  >>>
  >>> iterate_over(tf.constant([1, 2, 3]))
  Traceback (most recent call last):
  ...
  OperatorNotAllowedInGraphError: ...

  N)r   r   r   __doc__r   r   r   r   r   "   s    $ r   r   zerrors.OpErrorOpErrorc                   ~     e Zd ZdZ fdZd Zed        Zed        Zed        Z	ed        Z
ed        Zd	 Z xZS )
r   zThe base class for TensorFlow exceptions.

  Usually, TensorFlow will raise a more specific subclass of `OpError` from the
  `tf.errors` module.
  c                     t         t        |           || _        || _        || _        || _        |r|d   | _        yi | _        y)a  Creates a new `OpError` indicating that a particular op failed.

    Args:
      node_def: The `node_def_pb2.NodeDef` proto representing the op that
        failed, if known; otherwise None.
      op: The `ops.Operation` that failed, if known; otherwise None. During
        eager execution, this field is always `None`.
      message: The message string describing the failure.
      error_code: The `error_codes_pb2.Code` describing the error.
      *args: If not empty, it should contain a dictionary describing details
        about the error. This argument is inspired by Abseil payloads:
        https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
    r   N)superr   __init__	_node_def_op_message_error_code_experimental_payloads)selfnode_defopmessage
error_codeargs	__class__s         r   r   zOpError.__init__B   sF     
'4!#DNDHDM!D$(Gd!$&d!r   c                      t        j                   j                  j                        }t	         fd|j
                  dd  D              } j                  |fS )Nc              3   6   K   | ]  }t        |        y wN)getattr).0argr!   s     r   	<genexpr>z%OpError.__reduce__.<locals>.<genexpr>]   s     Es#Es      )r	   
getargspecr'   r   tupler&   )r!   init_argspecr&   s   `  r   
__reduce__zOpError.__reduce__Z   sI    (()@)@ALE|/@/@/DEED>>4r   c                     | j                   S )z+The error message that describes the error.)r   r!   s    r   r$   zOpError.message`   s     ==r   c                     | j                   S )a  The operation that failed, if known.

    *N.B.* If the failed op was synthesized at runtime, e.g. a `Send`
    or `Recv` op, there will be no corresponding
    `tf.Operation`
    object.  In that case, this will return `None`, and you should
    instead use the `tf.errors.OpError.node_def` to
    discover information about the op.

    Returns:
      The `Operation` that failed, or None.
    )r   r5   s    r   r#   z
OpError.ope   s     88Or   c                     | j                   S )z0The integer error code that describes the error.)r   r5   s    r   r%   zOpError.error_codeu   s     r   c                     | j                   S )z4The `NodeDef` proto representing the op that failed.)r   r5   s    r   r"   zOpError.node_defz   s     >>r   c                     | j                   S )z1A dictionary describing the details of the error.)r    r5   s    r   experimental_payloadszOpError.experimental_payloads   s     &&&r   c                    | j                   T| j                  d| j                   j                  dg}t        j                  | j                   j                  xs g       }|j                  |       | j                   j                  }||j                  d|j                  d       |}t        j                  |j                  xs g       }d}d}d }t        ||      D ]^  \  }}	||	k(  r |r|dz  }|}|j                  |       d}d}+|r!|dkD  r|j                  d	|dz
  fz  |g       d}|j                  |       ` |j                  }|d
j                  |      S | j                  S )Nz

Original stack trace for z:
z'
...which was originally created as op z, defined at:
Fr   r/   Tz4[elided %d identical lines from previous traceback]
 )
r   r$   name	tracebackformat_listextend_original_opappendzipjoin)
r!   outputcurr_traceback_listoriginal_opprev_traceback_list
is_elidingelide_countlast_elided_linelineline_in_prevs
             r   __str__zOpError.__str__   s   xx llhhmmf &11$((2D2D2JKmm'(HH))k# 	! 2'33K4I4I4ORP 
"%&9;N"O 	 D,\!Qk!%mmD!jkqK 1_&'(8  !jMM$#	 ( "..E #H WWV_\\r   )r   r   r   r   r   r3   propertyr$   r#   r%   r"   r:   rN   __classcell__r'   s   @r   r   r   9   s{    '0          ' '3r   z	errors.OKOKzerrors.CANCELLED	CANCELLEDzerrors.UNKNOWNUNKNOWNzerrors.INVALID_ARGUMENTINVALID_ARGUMENTzerrors.DEADLINE_EXCEEDEDDEADLINE_EXCEEDEDzerrors.NOT_FOUND	NOT_FOUNDzerrors.ALREADY_EXISTSALREADY_EXISTSzerrors.PERMISSION_DENIEDPERMISSION_DENIEDzerrors.UNAUTHENTICATEDUNAUTHENTICATEDzerrors.RESOURCE_EXHAUSTEDRESOURCE_EXHAUSTEDzerrors.FAILED_PRECONDITIONFAILED_PRECONDITIONzerrors.ABORTEDABORTEDzerrors.OUT_OF_RANGEOUT_OF_RANGEzerrors.UNIMPLEMENTEDUNIMPLEMENTEDzerrors.INTERNALINTERNALzerrors.UNAVAILABLEUNAVAILABLEzerrors.DATA_LOSS	DATA_LOSSzerrors.CancelledErrorc                   "     e Zd ZdZ fdZ xZS )CancelledErrora  Raised when an operation is cancelled.

  For example, a long-running operation e.g.`tf.queue.QueueBase.enqueue`, or a
  `tf.function` call may be cancelled by either running another operation e.g.
  `tf.queue.QueueBase.close` or a remote worker failure.

  This long-running operation will fail by raising `CancelledError`.

  Example:
  >>> q = tf.queue.FIFOQueue(10, tf.float32, ((),))
  >>> q.enqueue((10.0,))
  >>> q.close()
  >>> q.enqueue((10.0,))
  Traceback (most recent call last):
    ...
  CancelledError: ...

  c                 <    t        t        | 
  |||t        g|  y)zCreates a `CancelledError`.N)r   rd   r   rS   r!   r"   r#   r$   r&   r'   s        r   r   zCancelledError.__init__   s"    	.$(2w	 0*.0r   r   r   r   r   r   rP   rQ   s   @r   rd   rd      s    &0 0r   rd   zerrors.UnknownErrorc                   "     e Zd ZdZ fdZ xZS )UnknownErrora/  Unknown error.

  An example of where this error may be returned is if a Status value
  received from another address space belongs to an error-space that
  is not known to this address space. Also, errors raised by APIs that
  do not return enough error information may be converted to this
  error.
  c                 <    t        t        | 
  |||t        g|  y)zCreates an `UnknownError`.N)r   ri   r   rT   rf   s        r   r   zUnknownError.__init__	      	,&xWgMMr   rg   rQ   s   @r   ri   ri          N Nr   ri   zerrors.InvalidArgumentErrorc                   "     e Zd ZdZ fdZ xZS )InvalidArgumentErrorzRaised when an operation receives an invalid argument.

  This error is typically raised when an op receives mismatched arguments.

  Example:

  >>> tf.reshape([1, 2, 3], (2,))
  Traceback (most recent call last):
     ...
  InvalidArgumentError: ...
  c                 <    t        t        | 
  |||t        g|  y)z"Creates an `InvalidArgumentError`.N)r   rn   r   rU   rf   s        r   r   zInvalidArgumentError.__init__  s&    	
.xW/?HBFHr   rg   rQ   s   @r   rn   rn     s    
H Hr   rn   zerrors.DeadlineExceededErrorc                   "     e Zd ZdZ fdZ xZS )DeadlineExceededErrorznRaised when a deadline expires before an operation could complete.

  This exception is not currently used.
  c                 <    t        t        | 
  |||t        g|  y)z"Creates a `DeadlineExceededError`.N)r   rq   r   rV   rf   s        r   r   zDeadlineExceededError.__init__)  &    	
/"g0AJDHJr   rg   rQ   s   @r   rq   rq   "  s    
J Jr   rq   zerrors.NotFoundErrorc                   "     e Zd ZdZ fdZ xZS )NotFoundErrorzRaised when a requested entity (e.g., a file or directory) was not found.

  For example, running the
  `tf.WholeFileReader.read`
  operation could raise `NotFoundError` if it receives the name of a file that
  does not exist.
  c                 <    t        t        | 
  |||t        g|  y)zCreates a `NotFoundError`.N)r   ru   r   rW   rf   s        r   r   zNotFoundError.__init__9      	-'"gyP4Pr   rg   rQ   s   @r   ru   ru   /  s    Q Qr   ru   zerrors.AlreadyExistsErrorc                   "     e Zd ZdZ fdZ xZS )AlreadyExistsErrora  Raised when an entity that we attempted to create already exists.

  An API raises this this error to avoid overwriting an existing resource,
  value, etc. Calling a creation API multiple times with the same arguments
  could raise this error if the creation API is not idempotent.

  For example, running an operation that saves a file
  (e.g. `tf.saved_model.save`)
  could potentially raise this exception if an explicit filename for an
  existing file was passed.
  c                 <    t        t        | 
  |||t        g|  y)z Creates an `AlreadyExistsError`.N)r   ry   r   rX   rf   s        r   r   zAlreadyExistsError.__init__L  s&    	
d,Xr7-;D>BDr   rg   rQ   s   @r   ry   ry   >  s    
D Dr   ry   zerrors.PermissionDeniedErrorc                   "     e Zd ZdZ fdZ xZS )PermissionDeniedErrora  Raised when the caller does not have permission to run an operation.

  For example, running the
  `tf.WholeFileReader.read`
  operation could raise `PermissionDeniedError` if it receives the name of a
  file for which the user does not have the read file permission.
  c                 <    t        t        | 
  |||t        g|  y)z"Creates a `PermissionDeniedError`.N)r   r|   r   rY   rf   s        r   r   zPermissionDeniedError.__init__\  rs   r   rg   rQ   s   @r   r|   r|   R  s    J Jr   r|   zerrors.UnauthenticatedErrorc                   "     e Zd ZdZ fdZ xZS )UnauthenticatedErrorzsRaised when the request does not have valid authentication credentials.

  This exception is not currently used.
  c                 <    t        t        | 
  |||t        g|  y)z"Creates an `UnauthenticatedError`.N)r   r   r   rZ   rf   s        r   r   zUnauthenticatedError.__init__i  s&    	
.xW/>GAEGr   rg   rQ   s   @r   r   r   b  s    
G Gr   r   zerrors.ResourceExhaustedErrorc                   "     e Zd ZdZ fdZ xZS )ResourceExhaustedErrora\  Raised when some resource has been exhausted while running operation.

  For example, this error might be raised if a per-user quota is
  exhausted, or perhaps the entire file system is out of space. If running into
  `ResourceExhaustedError` due to out of memory (OOM), try to use smaller batch
  size or reduce dimension size of model weights.
  c                 <    t        t        | 
  |||t        g|  y)z#Creates a `ResourceExhaustedError`.N)r   r   r   r[   rf   s        r   r   zResourceExhaustedError.__init__y  s&    	
 $02w1CLFJLr   rg   rQ   s   @r   r   r   o  s    L Lr   r   zerrors.FailedPreconditionErrorc                   "     e Zd ZdZ fdZ xZS )FailedPreconditionErrora|  Raised when some prerequisites are not met when running an operation.

  This typically indicates that system is not in state to execute the operation
  and requires preconditions to be met before successfully executing current
  operation.

  For example, this exception is commonly raised when running an operation
  that reads a `tf.Variable` before it has been initialized.
  c                 <    t        t        | 
  |||t        g|  y)z$Creates a `FailedPreconditionError`.N)r   r   r   r\   rf   s        r   r   z FailedPreconditionError.__init__  s&    	
!41(B2ENHLNr   rg   rQ   s   @r   r   r     s    N Nr   r   zerrors.AbortedErrorc                   "     e Zd ZdZ fdZ xZS )AbortedErrorzRaised when an operation was aborted, typically due to a concurrent action.

  For example, running a
  `tf.queue.QueueBase.enqueue`
  operation may raise `AbortedError` if a
  `tf.queue.QueueBase.close` operation
  previously ran.
  c                 <    t        t        | 
  |||t        g|  y)zCreates an `AbortedError`.N)r   r   r   r]   rf   s        r   r   zAbortedError.__init__  rk   r   rg   rQ   s   @r   r   r     rl   r   r   zerrors.OutOfRangeErrorc                   "     e Zd ZdZ fdZ xZS )OutOfRangeErrora  Raised when an operation iterates past the valid range.

  Unlike `InvalidArgumentError`, this error indicates a problem may be fixed if
  the system state changes. For example, if a list grows and the operation is
  now within the valid range. `OutOfRangeError` overlaps with
  `FailedPreconditionError` and should be preferred as the more specific error
  when iterating or accessing a range.

  For example, iterating a TF dataset past the last item in the dataset will
  raise this error.
  c                 <    t        t        | 
  |||t        g|  y)zCreates an `OutOfRangeError`.N)r   r   r   r^   rf   s        r   r   zOutOfRangeError.__init__  s"    	/4)(B 1+/1r   rg   rQ   s   @r   r   r     s    
1 1r   r   zerrors.UnimplementedErrorc                   "     e Zd ZdZ fdZ xZS )UnimplementedErroraP  Raised when an operation has not been implemented.

  Some operations may raise this error when passed otherwise-valid
  arguments that it does not currently support. For example, running
  the `tf.nn.max_pool2d` operation
  would raise this error if pooling was requested on the batch dimension,
  because this is not yet supported.
  c                 <    t        t        | 
  |||t        g|  y)z Creates an `UnimplementedError`.N)r   r   r   r_   rf   s        r   r   zUnimplementedError.__init__  s&    	
d,Xr7-:C=ACr   rg   rQ   s   @r   r   r     s    C Cr   r   zerrors.InternalErrorc                   "     e Zd ZdZ fdZ xZS )InternalErrorzRaised when the system experiences an internal error.

  This exception is raised when some invariant expected by the runtime
  has been broken. Catching this exception is not recommended.
  c                 <    t        t        | 
  |||t        g|  y)zCreates an `InternalError`.N)r   r   r   r`   rf   s        r   r   zInternalError.__init__  s    	-'"gxO$Or   rg   rQ   s   @r   r   r     s    P Pr   r   zerrors.UnavailableErrorc                   "     e Zd ZdZ fdZ xZS )UnavailableErrorz]Raised when the runtime is currently unavailable.

  This exception is not currently used.
  c                 <    t        t        | 
  |||t        g|  y)zCreates an `UnavailableError`.N)r   r   r   ra   rf   s        r   r   zUnavailableError.__init__  s#    	
D*8R+ 2,02r   rg   rQ   s   @r   r   r     s    
2 2r   r   zerrors.DataLossErrorc                   "     e Zd ZdZ fdZ xZS )DataLossErrora9  Raised when unrecoverable data loss or corruption is encountered.

  This could be due to:
  * A truncated file.
  * A corrupted file.
  * Specifying the wrong data format.

  For example, this may be raised by running a
  `tf.WholeFileReader.read`
  operation, if the file is truncated while it is being read.
  c                 <    t        t        | 
  |||t        g|  y)zCreates a `DataLossError`.N)r   r   r   rb   rf   s        r   r   zDataLossError.__init__  rw   r   rg   rQ   s   @r   r   r     s    
Q Qr   r   z%errors.exception_type_from_error_codec                     t         |    S r*   )_CODE_TO_EXCEPTION_CLASS)r%   s    r   exception_type_from_error_coder     s    	!*	--r   z%errors.error_code_from_exception_typec                 z    	 t         |    S # t        $ r& t        j                  d       t	        d d dd       cY S w xY w)NzUnknown class exception)_EXCEPTION_CLASS_TO_CODEKeyErrorwarningswarnri   )clss    r   error_code_from_exception_typer     sC    E#C((	 EMM+,d$=tDDEs    ,::c                     	 t        |      } || ||      S # t        $ r) t        j                  d|z         t	        | |||      cY S w xY w)NzUnknown error code: %d)r   r   r   r   ri   )r"   r#   r$   r%   exc_types        r   _make_specific_exceptionr     sR    ;-j9HHb'**	 ;MM*Z78"gz::;s    /A	A	z'errors.raise_exception_on_not_ok_statusc                       e Zd ZdZd Zd Zy) raise_exception_on_not_ok_statusz*Context manager to check for C API status.c                 `    t        j                         | _        | j                  j                  S r*   )r   ScopedTFStatusstatusr5   s    r   	__enter__z*raise_exception_on_not_ok_status.__enter__,  s"    ++-DK;;r   c           	      P   	 t        j                  | j                  j                        dk7  rot        d d t	        j
                  t        j                  | j                  j                              t        j                  | j                  j                              	 | `y# | `w xY w)Nr   F)c_api
TF_GetCoder   r   r   as_text
TF_Message)r!   type_arg	value_argtraceback_args       r   __exit__z)raise_exception_on_not_ok_status.__exit__0  s    				$++,,	-	2&$u'7'78J8J'KLT[[//02 	2 
3 + +s   BB! !B%N)r   r   r   r   r   r   r   r   r   r   r   (  s    2r   r   )Er   r>   r   tensorflow.core.lib.corer   tensorflow.pythonr   tensorflow.python.clientr   r   tensorflow.python.frameworkr   tensorflow.python.utilr   r   r	    tensorflow.python.util.tf_exportr
   
ValueErrorr   	TypeErrorr   deprecated_endpoints	Exceptionr   rR   export_constantr   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rd   ri   rn   rq   ru   ry   r|   r   r   r   r   r   r   r   r   r   r   PyExceptionRegistry_Inititemsr   r   r   r   objectr   )codeclass_s   00r   <module>r      s   -   4 ; ? 2 ) . - 6j  2r:Y  ;, !19 =>!!!),|i | - ?|~  	+  & &x 6%%	 	
  - -h D

!
! 	
  + +Hi @"33  	
# $ 4 4X5GI#55  	
$ % 5 5h6IK%%	 	
  - -h D // 	
! " 2 28=M N#55  	
$ % 5 5h6IK!11 	
" # 3 3H>O P$77  	
% & 6 6x7KM%99  	
& ' 7 78MO

!
! 	
  + +Hi @++ 	
   0 0> J-- 	
  ! 1 1(O L## 	
  , ,Xz B)) 	
  / /- H%%	 	
  - -h D "#0W 0 $04  !N7 N "N ()H7 H *H& )*	JG 	J +	J !"QG Q #Q &'D D (D& )*JG J +J ()	G7 	G *	G *+LW L ,L +,Ng N -N"  !N7 N "N #$1g 1 %1& &'C C (C  !"	PG 	P #	P $%	2w 	2 &	2 !"QG Q #Q$~\ * ,	
 } & , ) . 0 \ / % m !  }! & 7  6 67O P &>%C%C%E!T6FDL 
 678. 9. 678E 9E; 89:v  ;Cs   (S5