o
    $i                     @   sN   d dl Zd dlmZ d dlmZ d dlmZ e \ZZ	eG dd deZ
dS )    N)try_import_torch)SeriesStats)DeveloperAPIc                   @   s2   e Zd ZdZdZdd Zdd Zdefdd	Zd
S )MaxStatszPA Stats object that tracks the max of a series of singular values (not vectors).maxc                 C   s
   t |S )N)npnanmax)selfvalues r   ^/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/rllib/utils/metrics/stats/max.py_np_reduce_fn   s   
zMaxStats._np_reduce_fnc                 C   s>   |t |  }t|dkrt jtd|jdS t | S )z1Reduce function for torch tensors (stays on GPU).r   nan)device)torchisnanlentensorfloatr   r   )r	   r
   clean_valuesr   r   r   _torch_reduce_fn   s   zMaxStats._torch_reduce_fnreturnc                 C   s"   d|    d| j dt|  dS )Nz	MaxStats(z	; window=z; len=))peek_windowr   )r	   r   r   r   __repr__   s   "zMaxStats.__repr__N)	__name__
__module____qualname____doc__stats_cls_identifierr   r   strr   r   r   r   r   r   
   s    	r   )numpyr   ray.rllib.utils.frameworkr   $ray.rllib.utils.metrics.stats.seriesr   ray.util.annotationsr   r   _r   r   r   r   r   <module>   s    
