
    &`i                         d dl Z d dlZd dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZmZ erd dlmZ  ej        e          Z G d dee j        	          ZdS )
    N)TYPE_CHECKINGAnyUnion)FaultAwareApply)MetricsLogger)
DeviceType
TensorType)AlgorithmConfigc                   ~    e Zd Zd fdZej        d             Zej        d             Zej        defd            Z	ej        defd            Z
ej        dd
            Zeej        deed	f         fd                        Zej        dd            Zej        dd            Zej        defd            Z xZS )Runnerconfigr
   c                F   |                     d          | _        |                    d          | _        |                                  |                                  d| _        t          |j        d          | _	        t                                                       dS )zInitializes a `Runner` instance.

        Args:
            config: The `AlgorithmConfig` to use to setup this `Runner`.
            **kwargs: Forward compatibility `kwargs`.
        worker_indexF)copy_frozenr   )stats_cls_lookuprootN)getr   copyr   
set_devicemake_module_weights_seq_nor   r   metricssuper__init__)selfr   kwargs	__class__s      r/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/rllib/utils/runners/runner.pyr   zRunner.__init__   s     "(N!;!;'-{{u{'E'E  '4#4'
 '
 '
 	    c                     dS )aD  Checks that self.__init__() has been completed properly.

        Useful in case an `Runner` is run as @ray.remote (Actor) and the owner
        would like to make sure the Ray Actor has been properly initialized.

        Raises:
            AssertionError: If the `Runner` Actor has NOT been properly initialized.
        N r   s    r   assert_healthyzRunner.assert_healthy(         r   c                     dS )a*  Creates the `RLModule` for this `Runner` and assigns it to `self.module`.

        Note that users should be able to change the `Runner`'s config (e.g. change
        `self.config.rl_module_spec`) and then call this method to create a new `RLModule`
        with the updated configuration.
        Nr!   r"   s    r   r   zRunner.make_module3   s	     	r   returnc                     dS )zRuns the `Runner`.

        The exact logic of this method could have very different forms.

        Args:
            **kwargs: Forward compatibility kwargs.

        Returns:
            Anything.
        Nr!   )r   r   s     r   runz
Runner.run=   r$   r   c                     dS )z|Returns metrics (in any form) of the logic run in this `Runner`.

        Returns:
            Metrics of any form.
        Nr!   r"   s    r   get_metricszRunner.get_metricsJ   r$   r   Nc                     dS )zReleases all resources used by this `Runner`.

        For example, when using a `gym.Env` in this `Runner`, you should make sure
        that its `close()` method is called.
        Nr!   r"   s    r   stopzRunner.stopR   r$   r   c                     dS )zHReturns the device of this `Runner`. None if framework is not supported.Nr!   r"   s    r   _devicezRunner._deviceZ   s	     	r   c                     dS )z"Sets the device for this `Runner`.Nr!   r"   s    r   r   zRunner.set_device`   s	     	r   c                     dS )z:If this Actor is deleted, clears all resources used by it.Nr!   r"   s    r   __del__zRunner.__del__e   r$   r   c                     dS )z0Converts structs to a framework-specific tensor.Nr!   )r   structs     r   _convert_to_tensorzRunner._convert_to_tensori   r$   r   )r   r
   )r&   N)__name__
__module____qualname__r   abcabstractmethodr#   r   r   r(   r*   r,   propertyr   r   r.   r   r1   r	   r4   __classcell__)r   s   @r   r   r      s            0 	   	   	
s 
 
 
 
 	S     	    z4/0     X 	    	I I I I 	?J ? ? ? ? ? ? ? ?r   r   )	metaclass)r8   loggingtypingr   r   r   ray.rllib.utils.actor_managerr   &ray.rllib.utils.metrics.metrics_loggerr   ray.rllib.utils.typingr   r	   %ray.rllib.algorithms.algorithm_configr
   	getLoggerr5   loggerABCMetar   r!   r   r   <module>rF      s    



  , , , , , , , , , , 9 9 9 9 9 9 @ @ @ @ @ @ 9 9 9 9 9 9 9 9 FEEEEEE		8	$	$\? \? \? \? \?_ \? \? \? \? \? \?r   