
    2Vh%#                     x   d dl Z d dl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 ej                  j                  ej                  j                  edd            ej                  j                  dd	      fZ e
d
      d        Z e
d      d        Z e
d      d        Zd Zd Zd ZddZd Zy)    Nwraps)backend)tree)keras_export)global_statez..
tensorflowpythonz'keras.config.enable_traceback_filteringc                  0    t        j                  dd       y)a  Turn on traceback filtering.

    Raw Keras tracebacks (also known as stack traces)
    involve many internal frames, which can be
    challenging to read through, while not being actionable for end users.
    By default, Keras filters internal frames in most exceptions that it
    raises, to keep traceback short, readable, and focused on what's
    actionable for you (your own code).

    See also `keras.config.disable_traceback_filtering()` and
    `keras.config.is_traceback_filtering_enabled()`.

    If you have previously disabled traceback filtering via
    `keras.config.disable_traceback_filtering()`, you can re-enable it via
    `keras.config.enable_traceback_filtering()`.
    traceback_filteringTNr   set_global_attribute     O/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/utils/traceback_utils.pyenable_traceback_filteringr      s    $ %%&;TBr   z(keras.config.disable_traceback_filteringc                  0    t        j                  dd       y)a  Turn off traceback filtering.

    Raw Keras tracebacks (also known as stack traces)
    involve many internal frames, which can be
    challenging to read through, while not being actionable for end users.
    By default, Keras filters internal frames in most exceptions that it
    raises, to keep traceback short, readable, and focused on what's
    actionable for you (your own code).

    See also `keras.config.enable_traceback_filtering()` and
    `keras.config.is_traceback_filtering_enabled()`.

    If you have previously disabled traceback filtering via
    `keras.config.disable_traceback_filtering()`, you can re-enable it via
    `keras.config.enable_traceback_filtering()`.
    r   FNr   r   r   r   disable_traceback_filteringr   '   s    $ %%&;UCr   z+keras.config.is_traceback_filtering_enabledc                  .    t        j                  dd      S )a%  Check if traceback filtering is enabled.

    Raw Keras tracebacks (also known as stack traces)
    involve many internal frames, which can be
    challenging to read through, while not being actionable for end users.
    By default, Keras filters internal frames in most exceptions that it
    raises, to keep traceback short, readable, and focused on what's
    actionable for you (your own code).

    See also `keras.config.enable_traceback_filtering()` and
    `keras.config.disable_traceback_filtering()`.

    If you have previously disabled traceback filtering via
    `keras.config.disable_traceback_filtering()`, you can re-enable it via
    `keras.config.enable_traceback_filtering()`.

    Returns:
        Boolean, `True` if traceback filtering is enabled,
        and `False` otherwise.
    r   T)r   get_global_attributer   r   r   is_traceback_filtering_enabledr   <   s    , ,,-BDIIr   c                 &    t         D ]  }|| v s y y)NFT)_EXCLUDED_PATHS)fname	exclusions     r   include_framer   U   s!    $ 	 r   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                fd       }|S )zFFilter out Keras-internal traceback frames in exceptions raised by fn.c                      t               s | i |S d }	  | i |~S # t        $ r,}t        |j                        }|j	                  |      d d }~ww xY w# ~w xY wN)r   	Exceptionr-   __traceback__with_traceback)argskwargsfiltered_tbefns       r   error_handlerz'filter_traceback.<locals>.error_handlern   sp    -/t&v&&	t&v&   	:3AOODK "";/T9		: s      	A'AAA Ar   )r8   r9   s   ` r   filter_tracebackr:   k   s#     2Y  r   c                 v     t        j                          dk(  rddlm ndt                fd       }|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`.
    r	   r   )errorsNc            	      l   t               s | i |S 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 ]y  }|j                  |j                  v r2t        j                  t        |j                  |j                           }n|j                  }|j!                  d|j                   d|        { |rdj#                  |      }#t%        |j&                        r|j(                  }n|j*                  r|j*                  d   }nd}rnj,                   }	d|	 d| d	|	 d
| }It%        |j&                        r3|j/                  |j0                  |j2                  ||j4                        }
n-	 |j/                  |      }
n# t        $ r t7        |      }
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.

[1mz[0m

Arguments received by z:
T)r   r1   hasattrinspect	signaturebind	TypeErrorr   
parametersvaluesname	argumentsr   map_structureformat_argument_valuedefaultappendjoin
isinstanceOpErrormessager4   __name__	__class__node_defop
error_codeRuntimeErrorr>   r3   r2   )r4   r5   rD   bound_signaturer7   arguments_contextargvaluerR   display_namenew_er8   object_name	tf_errorss              r   r9   z8inject_argument_info_in_traceback.<locals>.error_handler   sS   -/t&v&&	>	 t&v&x y  9	Bq56))"-I"0)..$"A&"A 
 !#I00779: F88888 ..-'11#((;E
  KKE!((6#((1UG)DEF !$(II.?$@!(Z9;L;L-MiiGVV  ffQiG G1<+"++!N9, H%Y '--9N#()+  (Z9;L;L-MKK

ADD'1<<PE6 !"G 4$ 6 !-W 56 37/&&q7TAs9	Bv s]   # 
H,#H'A$#H'$A00E$H'G'&H''G>;H'=G>>)H''H,,H/ /H3)r   r	   r<   r   )r8   r_   r9   r`   s   `` @r   !inject_argument_info_in_tracebackra      s=     L(2	
2YD  D L r   c                 z   t        j                  |       rt        j                          dk(  rd}nPt        j                          dk(  rd}n6t        j                          dk(  rd}nt        j                          dk(  rd}nd	}| d
| j                   dt        j                  | j                         dS t        |       S )Nr	   z	tf.Tensorjaxzjnp.ndarraytorchztorch.Tensornumpyz
np.ndarrayarrayz(shape=z, dtype=))r   	is_tensorshapestandardize_dtypedtyperepr)r\   
tensor_clss     r   rL   rL      s     ??,$J__%'&J__')'J__')%J J l'%++ /..u{{;<A?	
 ;r   r0   )rC   osr    r%   	functoolsr   	keras.srcr   r   keras.src.api_exportr   keras.src.backend.commonr   pathabspathrO   __file__r   r   r   r   r   r-   r:   ra   rL   r   r   r   <module>rv      s     	      - 1 GGOOBGGLL467GGLLx( 78C 9C( 89D :D( ;<J =J0,Zzr   