
    2Vh.                        d dl Z d dlZd dlmZ dadadadZdada	 eddg      d	        Z
 ed
dg      d        Z eddg      d        Z eddg      d        Z eddg      d        Z eddg      d        Z ed      d        Z ed      d        Z ed      d        Zd Zd ej(                  v rej(                  j+                  d       ZnVej.                  j1                  d!      Z ej4                  eej6                        sd"Zej.                  j9                  ed#      Zd$ Zej.                  j1                  ej.                  j9                  ed%            Zej.                  j?                  e      r	  e e      5 Z! e jD                  e!      Z#ddd       e#j+                  d& e
             Z%e%d'v sJ e#j+                  d( e             Z& e'e&e(      sJ e#j+                  d)e      Z)e#j+                  d* e             Z*e*d+v sJ  ee%        ee&        ee*       e)Zej.                  j?                  e      s	  ejV                  e       ej.                  j?                  e      sL e
        e       e e       d,Z#	  e ed-      5 Z!e!j[                   e j\                  e#d./             ddd       d0ej(                  v rej(                  d0   Z)e)re)Zd1ej(                  v r e0ej(                  d1         ad2ej(                  v r e0ej(                  d2         a	edk7  rd3ej(                  d4<    ed5d6g      d7        Z1 ed8g      d9        Z2 ed:g      d;        Z3 ed<g      d=        Z4 ed>g      d?        Z5y# 1 sw Y   xY w# e$$ r i Z#Y w xY w# e,$ r Y Rw xY w# 1 sw Y   xY w# e/$ r Y w xY w)@    N)keras_exportfloat32gHz>channels_last
tensorflowzkeras.config.floatxzkeras.backend.floatxc                      t         S )zReturn the default float type, as a string.

    E.g. `'bfloat16'`, `'float16'`, `'float32'`, `'float64'`.

    Returns:
        String, the current default float type.

    Example:

    >>> keras.config.floatx()
    'float32'

    )_FLOATX     H/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/backend/config.pyfloatxr      s	     Nr
   zkeras.config.set_floatxzkeras.backend.set_floatxc                 L    h d}| |vrt        d|  d|       t        |       ay)a  Set the default float dtype.

    Note: It is not recommended to set this to `"float16"` for training,
    as this will likely cause numeric stability issues.
    Instead, mixed precision, which leverages
    a mix of `float16` and `float32`. It can be configured by calling
    `keras.mixed_precision.set_dtype_policy('mixed_float16')`.

    Args:
        value: String; `'bfloat16'`, `'float16'`, `'float32'`, or `'float64'`.

    Examples:
    >>> keras.config.floatx()
    'float32'

    >>> keras.config.set_floatx('float64')
    >>> keras.config.floatx()
    'float64'

    >>> # Set it back to float32
    >>> keras.config.set_floatx('float32')

    Raises:
        ValueError: In case of invalid value.
    >   float16r   float64bfloat16zUnknown `floatx` value: z. Expected one of N)
ValueErrorstrr   )valueaccepted_dtypess     r   
set_floatxr   )   sA    8 DOO#&ug ../1
 	
 %jGr
   zkeras.config.epsilonzkeras.backend.epsilonc                      t         S )zReturn the value of the fuzz factor used in numeric expressions.

    Returns:
        A float.

    Example:

    >>> keras.config.epsilon()
    1e-07

    _EPSILONr	   r
   r   epsilonr   N   s	     Or
   zkeras.config.set_epsilonzkeras.backend.set_epsilonc                     | a y)aW  Set the value of the fuzz factor used in numeric expressions.

    Args:
        value: float. New value of epsilon.

    Examples:
    >>> keras.config.epsilon()
    1e-07

    >>> keras.config.set_epsilon(1e-5)
    >>> keras.config.epsilon()
    1e-05

    >>> # Set it back to the default value.
    >>> keras.config.set_epsilon(1e-7)

    Nr   )r   s    r   set_epsilonr   ^   s	    ( Hr
   zkeras.config.image_data_formatzkeras.backend.image_data_formatc                      t         S )zReturn the default image data format convention.

    Returns:
        A string, either `'channels_first'` or `'channels_last'`.

    Example:

    >>> keras.config.image_data_format()
    'channels_last'

    )_IMAGE_DATA_FORMATr	   r
   r   image_data_formatr   u   s
    $ r
   z"keras.config.set_image_data_formatz#keras.backend.set_image_data_formatc                 ^    t        |       j                         } | dvrt        d|        | ay)a  Set the value of the image data format convention.

    Args:
        data_format: string. `'channels_first'` or `'channels_last'`.

    Examples:

    >>> keras.config.image_data_format()
    'channels_last'

    >>> keras.config.set_image_data_format('channels_first')
    >>> keras.config.image_data_format()
    'channels_first'

    >>> # Set it back to `'channels_last'`
    >>> keras.config.set_image_data_format('channels_last')

    >   r   channels_firsteThe `data_format` argument must be one of {'channels_first', 'channels_last'}. Received: data_format=N)r   lowerr   r   data_formats    r   set_image_data_formatr%      sD    4 k"((*K==%%0M3
 	

 %r
   z#keras.config.enable_flash_attentionc                  4    ddl m}  | j                  dd       y)a  Enable flash attention.

    Flash attention offers performance optimization for attention layers,
    making it especially useful for large language models (LLMs) that
    benefit from faster and more memory-efficient attention computations.

    Once enabled, supported layers like `MultiHeadAttention` will **attempt** to
    use flash attention for faster computations. By default, this feature is
    enabled.

    Note that enabling flash attention does not guarantee it will always be
    used. Typically, the inputs must be in `float16` or `bfloat16` dtype, and
    input layout requirements may vary depending on the backend.
    r   global_stateflash_attentionNkeras.src.backend.commonr(   set_global_attributer'   s    r   enable_flash_attentionr-      s      6%%&7>r
   z$keras.config.disable_flash_attentionc                  4    ddl m}  | j                  dd       y)aq  Disable flash attention.

    Flash attention offers performance optimization for attention layers,
    making it especially useful for large language models (LLMs) that
    benefit from faster and more memory-efficient attention computations.

    Once disabled, supported layers like `MultiHeadAttention` will not
    use flash attention for faster computations.
    r   r'   r)   FNr*   r'   s    r   disable_flash_attentionr/      s     6%%&7?r
   z'keras.config.is_flash_attention_enabledc                  4    ddl m}  | j                  dd      S )a  Checks whether flash attention is globally enabled in Keras.

    Flash attention is a performance-optimized method for computing attention
    in large models, such as transformers, allowing for faster and more
    memory-efficient operations. This function checks the global Keras
    configuration to determine if flash attention is enabled for compatible
    layers (e.g., `MultiHeadAttention`).

    Note that enabling flash attention does not guarantee it will always be
    used. Typically, the inputs must be in `float16` or `bfloat16` dtype, and
    input layout requirements may vary depending on the backend.

    Returns:
        `False` if disabled; otherwise, it indicates that it is enabled.
    r   r'   r)   N)default)r+   r(   get_global_attributer'   s    r   is_flash_attention_enabledr3      s    " 6,,->,MMr
   c                 t    | 
t               S t        |       j                         } | dvrt        d|        | S )N>   r   r    r!   )r   r   r"   r   r#   s    r   standardize_data_formatr5      sQ     ""k"((*K==%%0M3
 	

 r
   
KERAS_HOME~z/tmpz.kerasc                      t         S )N)
_KERAS_DIRr	   r
   r   
keras_homer:     s    r
   z
keras.jsonr   >   r   r   r   r   backendr   >   r   r    )r   r   r;   r   w   )indentKERAS_BACKENDKERAS_MAX_EPOCHSKERAS_MAX_STEPS_PER_EPOCHtrueTF_FORCE_GPU_ALLOW_GROWTHzkeras.config.backendzkeras.backend.backendc                      t         S )a  Publicly accessible method for determining the current backend.

    Returns:
        String, the name of the backend Keras is currently using. One of
            `"tensorflow"`, `"torch"`, or `"jax"`.

    Example:

    >>> keras.config.backend()
    'tensorflow'

    )_BACKENDr	   r
   r   r;   r;   C  s	    & Or
   zkeras.config.set_max_epochsc                     | a y)a  Limit the maximum number of epochs for any call to fit.

    This will cap the number of epochs for any training run using `model.fit()`.
    This is purely for debugging, and can also be set via the `KERAS_MAX_EPOCHS`
    environment variable to quickly run a script without modifying its source.

    Args:
        max_epochs: The integer limit on the number of epochs or `None`. If
            `None`, no limit is applied.
    N_MAX_EPOCHS)
max_epochss    r   set_max_epochsrJ   Y  s	     Kr
   z$keras.config.set_max_steps_per_epochc                     | a y)a  Limit the maximum number of steps for any call to fit/evaluate/predict.

    This will cap the number of steps for single epoch of a call to `fit()`,
    `evaluate()`, or `predict()`. This is purely for debugging, and can also be
    set via the `KERAS_MAX_STEPS_PER_EPOCH` environment variable to quickly run
    a scrip without modifying its source.

    Args:
        max_epochs: The integer limit on the number of epochs or `None`. If
            `None`, no limit is applied.
    N_MAX_STEPS_PER_EPOCH)max_steps_per_epochs    r   set_max_steps_per_epochrO   i  s
     /r
   zkeras.config.max_epochsc                      t         S )a5  Get the maximum number of epochs for any call to fit.

    Retrieves the limit on the number of epochs set by
    `keras.config.set_max_epochs` or the `KERAS_MAX_EPOCHS` environment
    variable.

    Returns:
        The integer limit on the number of epochs or `None`, if no limit has
        been set.
    rG   r	   r
   r   rI   rI   z  s
     r
   z keras.config.max_steps_per_epochc                      t         S )aj  Get the maximum number of steps for any call to fit/evaluate/predict.

    Retrieves the limit on the number of epochs set by
    `keras.config.set_max_steps_per_epoch` or the `KERAS_MAX_STEPS_PER_EPOCH`
    environment variable.

    Args:
        max_epochs: The integer limit on the number of epochs or `None`. If
            `None`, no limit is applied.
    rL   r	   r
   r   rN   rN     s
      r
   )6jsonoskeras.src.api_exportr   r   r   r   rE   rH   rM   r   r   r   r   r   r%   r-   r/   r3   r5   environgetr9   path
expanduser_keras_base_diraccessW_OKjoinr:   _config_pathexistsopenfload_configr   _floatx_epsilon
isinstancefloat_backend_image_data_formatmakedirsOSErrorwritedumpsIOErrorintr;   rJ   rO   rI   rN   r	   r
   r   <module>ro      s    	 -   %     $&<=> ?" (*DEF! G!H %'>?@ A )+FGH I, () ,-%%< 34? 5?( 45@ 6@ 78N 9N*
 2::-Jgg((-O299_bgg. ox8J ww!!"'',,z<"HI77>>,, 	#1diilG	# kk(FH-G7777{{9gi0Hh&&&{{9h/H %8:K:MN!DDDDw,-H 
ww~~j!J 
ww~~l#(9.0	G,$ 	3GGJDJJwq12	3 bjj zz/*H#bjj!345K"**,rzz*EFG| /5BJJ*+   ,-. / 567/ 8/  ()* + 123  4 A	# 	# &   		3 	3 sf   <N NN N 	N7 $N+4N7 N	N NNN('N(+N40N7 7O ?O 