o
    $i                     @   s   d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZmZ d dlmZ eeZeG dd de jZdS )	    N)AnyDict)Dataset)Policy)DeveloperAPIExperimentalAPI)SampleBatchTypec                
   @   s   e Zd ZdZedefddZejede	de
eef fddZede	de
eef fd	d
Zee ddedede
eef fddZdS )OfflineEvaluatorz.Interface for an offline evaluator of a policypolicyc                 K   s
   || _ dS )zInitializes an OffPolicyEstimator instance.

        Args:
            policy: Policy to evaluate.
            kwargs: forward compatibility placeholder.
        N)r
   )selfr
   kwargs r   `/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/rllib/offline/offline_evaluator.py__init__   s   
zOfflineEvaluator.__init__batchreturnc                 K   s   t )aP  Returns the evaluation results for the given batch of episodes.

        Args:
            batch: The batch to evaluate.
            kwargs: forward compatibility placeholder.

        Returns:
            The evaluation done on the given batch. The returned
            dict can be any arbitrary mapping of strings to metrics.
        )NotImplementedErrorr   r   r   r   r   r   estimate   s   zOfflineEvaluator.estimatec                 K   s   i S )a6  Sometimes you need to train a model inside an evaluator. This method
        abstracts the training process.

        Args:
            batch: SampleBatch to train on
            kwargs: forward compatibility placeholder.

        Returns:
            Any optional metrics to return from the evaluator
        r   r   r   r   r   train+   s   zOfflineEvaluator.train)n_parallelismdatasetr   c                C   s   dS )a  Calculates the estimate of the metrics based on the given offline dataset.

        Typically, the dataset is passed through only once via n_parallel tasks in
        mini-batches to improve the run-time of metric estimation.

        Args:
            dataset: The ray dataset object to do offline evaluation on.
            n_parallelism: The number of parallelism to use for the computation.

        Returns:
            Dict[str, Any]: A dictionary of the estimated values.
        Nr   )r   r   r   r   r   r   estimate_on_dataset9   s    z$OfflineEvaluator.estimate_on_datasetN)__name__
__module____qualname____doc__r   r   r   abcabstractmethodr   r   strr   r   r   r   os	cpu_countr   intr   r   r   r   r   r	      s$    	
r	   )r   loggingr    typingr   r   ray.datar   ray.rllib.policyr   ray.rllib.utils.annotationsr   r   ray.rllib.utils.typingr   	getLoggerr   loggerABCr	   r   r   r   r   <module>   s    
