
    ij-                     n    d dl Z 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	  ed       G d d             Z
y)    N)keras_export)io_utilszkeras.utils.Progbarc                   @    e Zd ZdZ	 	 	 	 	 	 ddZd	dZd
dZd Zd Zy)Progbara  Displays a progress bar.

    If neither of `stateful_metrics` and `stateless_metrics` is provided, all
    metrics are assumed to be stateless (averaged by the progress bar before
    display).

    Args:
        target: Total number of steps expected, None if unknown.
        width: Progress bar width on screen.
        verbose: Verbosity mode, 0 (silent), 1 (verbose), 2 (semi-verbose)
        stateful_metrics: Iterable of string names of metrics that should *not*
            be averaged over time. Metrics in this list will be displayed as-is.
            If provided, do not provide `stateless_metrics`.
        stateless_metrics: Iterable of string names of metrics that *should* be
            averaged over time. Metrics in this list will be averaged by the
            progbar before display. If provided, do not provide
            `stateful_metrics`.
        interval: Minimum visual progress update interval (in seconds).
        unit_name: Display name for step counts (usually "step" or "sample").
    Nc                    ||t        d      || _        || _        || _        || _        || _        |t        |      | _        d | _        n0|d | _        t        |      | _        nt               | _        d | _        t        t        j                  d      xr t        j                  j                         xs: dt        j                  v xs& dt        j                  v xs dt        j                  v | _        d| _        i | _        g | _        t)        j(                         | _        d| _        | j*                  | _        d | _        d| _        y )Na   Only one of `stateful_metrics` or `stateless_metrics` can be provided. `stateful_metrics` is used to make metrics stateless by default (with an exclusion list), while `stateless_metrics` is used to make metrics stateful by default (with an exclusion list).isatty	ipykernelposixPYCHARM_HOSTEDr   )
ValueErrortargetwidthverboseinterval	unit_namesetstateful_metricsstateless_metricshasattrsysstdoutr   modulesosenviron_dynamic_display_seen_so_far_values_values_ordertime_start_last_update_time_at_epoch_start_time_after_first_step_prev_total_width)selfr   r   r   r   r   r   r   s           l/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/keras/src/utils/progbar.py__init__zProgbar.__init__#   s<    ',=,I4  
 "'$'(8$9D!%)D"*$(D!%():%;D"$'ED!%)D" SZZ*Bszz/@/@/B .ckk).#++%.  2::-	 	  iik$(KK!&*#!"    c                    || j                   d}n|| j                   k\  }|xs g }|D ]  \  }}|| j                  vr| j                  j                  |       | j                  || j                  v}n|| j                  v }|r|r|dg| j
                  |<   nt        || j                  z
  d      }|| j
                  vr||z  |g| j
                  |<   | j
                  |   dxx   ||z  z  cc<   | j
                  |   dxx   |z  cc<   |dg| j
                  |<    || _        d}d}	t        j                         }
| j                  ||
      }| j                  dk(  r|
| j                  z
  | j                  k  r|sy| j                  r|d| j                  z  z  }|dz  }n|dz  }| j                   | j                   dkD  rt        t!        j"                  | j                               dz   }d	| d
|| j                   fz  }d| d}|	dz  }	t%        |      | j                   z  }t        | j&                  |z        }|dkD  r|dd|z   dz  }|	dz  }	|dd| j&                  |z
  z   dz  }|	dz  }	nd|z  }||z  }| j                   \| j                   dkD  rM|sK|| j                   |z
  z  }|dkD  rd|dz  |dz  dz  |dz  fz  }n|dkD  rd|dz  |dz  fz  }nd|z  }d| d}nd|
| j(                  z
  dd}|	dz  }	|| j+                  || j,                        z  }| j                  D ]  }|d| dz  }t/        | j
                  |   t0              rh| j
                  |   \  }}t/        |t$              st3        j4                  |      }|t        d|      z  }t7        |      dkD  r
|d|d z  }|d|d!z  }|d| j
                  |    z  } ||z  }t9        |      t9        |      z   |	z
  }| j                  |kD  r|d| j                  |z
  z  z  }|r|dz  }t;        j<                  |d"       || _        d}|
| _        y| j                  d#k(  r3|r0| j                   #| j                   dkD  rt        t!        j"                  | j                               dz   }d	| d
|| j                   fz  }| d|
| j(                  z
  dd$}|d%| j+                  || j,                         z  }| j                  D ]i  }|d| dz  }| j
                  |   \  }}t/        |t$              st3        j4                  |      }|t        d|      z  }|dkD  r
|d|d z  }a|d|d!z  }k |dz  }||z  }t;        j<                  |d"       d}|
| _        y)&a  Updates the progress bar.

        Args:
            current: Index of current step.
            values: List of tuples: `(name, value_for_last_step)`. If `name` is
                in `stateful_metrics`, `value_for_last_step` will be displayed
                as-is. Else, an average of the metric over time will be
                displayed.
            finalize: Whether this is the last update for the progress bar. If
                `None`, defaults to `current >= self.target`.
        NF   r    
%zd/%dz[1mz[0m    z[32mu   ━z[0m	   z[37mz%7d/Unknowni  z%d:%02d:%02d<   z%d:%02dz%dsz [1m.0fzs[0mz - :MbP? z.4fz.4e)
line_break   sz -)r   r   appendr   r   r   maxr   r   _estimate_step_durationr   r!   r   r   r$   intmathlog10floatr   r    _format_timer   
isinstancelistnpmeanabslenr   	print_msg)r%   currentvaluesfinalizekv	stateless
value_basemessagespecial_char_lennowtime_per_unit	numdigitsbarprog
prog_widtheta
eta_formatinfocountavgtotal_widths                         r&   updatezProgbar.updateU   s    {{" "dkk12 	)DAq***""))!,$$0T%:%::	!7!77	 '(!fDLLO!$Wt/@/@%@!!DJ,+,z>:*FQQ*a*n<*Q*j8*
 $%a&Q9	): $iik44WcB<<1T&&&6x$$4$"8"88844{{&4;;?

4;; 781<	9+T*w.DDuH- A% W~3 d!23
>WUZ%7$8@@C$)$$**z*A!B C7KK A%  $g-sNG {{&4;;?8#t{{W'<=:!/tt*b3 "J
 2X!*cRir-B!BJ!&J!*W5 "#"3C!8A! D%%mT^^DDD '' 2#aS
"dll1ot4$(LLOMFE%fe4!# 3q%=0C3x$!C9-!C9-aQ011D2 tOGc(SY.1AAK%%33$"8"8;"FGG4w59%0D"G.  + \\QDKK3a

4;; 781<	I;d+w.DDC$++$5c#:!<"T..}dnnMNOO++ 	.Ac!AJ&D$(LLOMFE%fe4!# 3q%=0CTz!C9-!C9-	. 4""7u=r(   c                 B    | j                  | j                  |z   |       y N)r^   r   )r%   nrJ   s      r&   addzProgbar.add   s    D%%)62r(   c                     d}|dk\  s|dk(  r|d|dd| z  }|S |dk\  r|d|dz  dd	| z  }|S |d|d
z  dd| z  }|S )a  format a given duration to display to the user.

        Given the duration, this function formats it in either milliseconds
        or seconds and displays the unit (i.e. ms/step or s/epoch).

        Args:
            time_per_unit: the duration to display
            unit_name: the name of the unit to display

        Returns:
            A string with the correctly formatted duration and units
        r+   r*   r   r6   r3   zs/r5   g     @@zms/g    .Azus/ )r%   rS   r   	formatteds       r&   rA   zProgbar._format_time   s     	A!!31]3/r)==I
 	 d"1]V3C8I;GGI  1]Y6s;3ykJJIr(   c                     |rG| j                   |dkD  r|| j                   z
  |dz
  z  }n|| j                  z
  |z  }|dk(  r|| _         |S y)a  Estimate the duration of a single step.

        Given the step number `current` and the corresponding time `now` this
        function returns an estimate for how long a single step takes. If this
        is called before one step has been completed (i.e. `current == 0`) then
        zero is given as an estimate. The duration estimate ignores the duration
        of the (assumed to be non-representative) first step for estimates when
        more steps are available (i.e. `current>1`).

        Args:
            current: Index of current step.
            now: The current time.

        Returns: Estimate of the duration of a single step.
        r*   r   )r#   r    )r%   rI   rR   rS   s       r&   r<   zProgbar._estimate_step_duration  sd       **67Q;!$t'B'B!BaK! "%t{{!2g =!|.1+  r(   )   r*   g?NNstep)NNr`   )	__name__
__module____qualname____doc__r'   r^   rb   rA   r<   rd   r(   r&   r   r      s7    0 0#dX t3,"r(   r   )r>   r   r   r   numpyrD   keras.src.api_exportr   keras.src.utilsr   r   rd   r(   r&   <module>rp      s<     	 
   - $ #$] ] %]r(   