
    0h                        d Z ddlZddlZddlZddlZddlZddlmc mZ	 ej                  j                  ej                  j                  edd            ej                  j                  dd      fZd Zd Zd Zdd	Zd
 Zy)z@Utilities related to TF-Keras exception stack trace prettifying.    Nz..
tensorflowpythonc                 &    t         D ]  }|| v s y y)NFT)_EXCLUDED_PATHS)fname	exclusions     \/var/www/html/engine/venv/lib/python3.12/site-packages/tf_keras/src/utils/traceback_utils.pyinclude_framer
      s!    $ 	     c                 L   d}t        t        j                  |             }t        |      D ]G  \  }}t	        |j
                  j                        s&t        j                  |||j                  |      }I |,|r*|d   \  }}t        j                  |||j                  |      }|S )zFIterate through traceback frames and return a new, filtered traceback.N)
list	tracebackwalk_tbreversedr
   f_codeco_filenametypesTracebackTypef_lasti)tblast_tbtb_listfline_nos        r	   _process_traceback_framesr   &   s    G9$$R()Gw' J
7--.))'1aiiIGJ 7 R[
7%%gq!))WENr   c                      t         j                  j                  dk7  st         j                  j                  dk  r S  fd}t        j
                  j                  j                   |      S )zLFilter out Keras-internal stack trace frames in exceptions raised by
    fn.      c                      t         j                  j                         s | i |S d }	  | i |~S # t        $ r,}t	        |j
                        }|j                  |      d d }~ww xY w# ~w xY wN)tf	debuggingis_traceback_filtering_enabled	Exceptionr   __traceback__with_traceback)argskwargsfiltered_tbefns       r	   error_handlerz'filter_traceback.<locals>.error_handler;   sz    ||::<t&v&&	t&v&   	:3AOODK "";/T9		: s    4 	A)'A$$A))A, ,A/)sysversion_infomajorminorr"   __internal__	decoratormake_decorator)r,   r-   s   ` r	   filter_tracebackr5   5   sU     "c&6&6&<&<q&@	 ??$$33BFFr   c                 f      fd}t         j                  j                  j                   |      S )a  Add information about call argument values to an error message.

    Arguments:
      fn: Function to wrap. Exceptions raised by the this function will be
        re-raised with additional information added to the error message,
        displaying the values of the different arguments that the function
        was called with.
      object_name: String, display name of the class/function being called,
        e.g. `'layer "layer_name" (LayerClass)'`.

    Returns:
      A wrapped version of `fn`.
    c            	         d }d }	  | i |~~S # t         $ r"}t        |d      r|t        j                        }	  |j                  | i |}n# t
        $ r |w xY wg }t        |j                  j                               D ]  }|j                  |j                  v r<t        j                  j                  t        |j                  |j                           }n|j                  }|j!                  d|j                   d|         |rdj#                  |      }t%        |t        j&                  j(                        r|j*                  }n|j,                  r|j,                  d   }nd}rnj.                   }	d|	 d| d	|	 d
| }t%        |t        j&                  j(                        r3|j1                  |j2                  |j4                  ||j6                        }
n-	 |j1                  |      }
n# t
        $ r t9        |      }
Y nw xY wd|
_        n|}
|
j=                  |j>                        d d }~ww xY w# ~~w xY w)N_keras_call_info_injectedu     • =
r    z#Exception encountered when calling z.

z

Call arguments received by z:
T) r%   hasattrinspect	signaturebind	TypeErrorr   
parametersvaluesname	argumentsr"   nestmap_structureformat_argument_valuedefaultappendjoin
isinstanceerrorsOpErrormessager(   __name__	__class__node_defop
error_codeRuntimeErrorr8   r'   r&   )r(   r)   r>   bound_signaturer+   arguments_contextargvaluerN   display_namenew_er,   object_names              r	   r-   z8inject_argument_info_in_traceback.<locals>.error_handler\   s;   	?	 t&v&z {  :	Bq56))"-I"0)..$"A&"A 
 !#I00779: F88888GG11-'11#((;E
  KKE!((6#((1UG)DEF !$(II.?$@!a!2!23iiGVV  ffQiG G1<+"++!N9,ui  22>s()+  a!2!23KK

ADD'1<<PE6 !"G 4$ 6 !-W 56 37/&&q7TAu:	Bx s\    
H=#H8AH8AFH8&G87H88HH8H)H88H==I   I)r"   r2   r3   r4   )r,   r[   r-   s   `` r	   !inject_argument_info_in_tracebackr\   M   s)    B H ??$$33BFFr   c                     t        | t        j                        r'd| j                   d| j                  j
                   dS t        |       S )Nztf.Tensor(shape=z, dtype=))rK   r"   TensorshapedtyperC   repr)rX   s    r	   rG   rG      s@    %# "%++hu{{7G7G6HJJ;r   r!   )__doc__r=   osr.   r   r   tensorflow.compat.v2compatv2r"   pathabspathrJ   __file__r   r
   r   r5   r\   rG    r   r	   <module>rl      sy    G  	 
   ! ! GGOOBGGLL467GGLLx(G0SGlr   