
    &`i	                         d dl mZmZmZmZ d dlmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZmZmZ ededeeeegef         d	ee         fd
            Z e edd                     ZdS )    )AnyCallableDictType)ActionConnectorConnectorContext)register_connector)OldAPIStackconvert_to_numpy)ActionConnectorDataTypePolicyOutputTypeStateBatchesTensorStructTypenamefnreturnc                 v      G  fddt                      _         _        t                      S )a  A util to register any function transforming PolicyOutputType as an ActionConnector.

    The only requirement is that fn should take actions, states, and fetches as input,
    and return transformed actions, states, and fetches.

    Args:
        name: Name of the resulting actor connector.
        fn: The function that transforms PolicyOutputType.

    Returns:
        A new ActionConnector class that transforms PolicyOutputType using fn.
    c                   R    e Zd ZdedeffdZfdZededef fd            Z	dS )	?register_lambda_action_connector.<locals>.LambdaActionConnectorac_datar   c           
          t          |j        t                    s
J d            |j        \  }}}t          |j        |j        |j         |||                    S )Nz0Action connector requires PolicyOutputType data.)
isinstanceoutputtupler   env_idagent_id
input_dict)selfr   actionsstatesfetchesr   s        w/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/rllib/connectors/action/lambdas.py	transformzIregister_lambda_action_connector.<locals>.LambdaActionConnector.transform$   s}       B BAB B  (/~$GVW* "7FG,,	      c                     d fS N )r   r   s    r#   to_statezHregister_lambda_action_connector.<locals>.LambdaActionConnector.to_state3   s    :r%   ctxparamsc                      |           S r'   r(   )r*   r+   LambdaActionConnectors     r#   
from_statezJregister_lambda_action_connector.<locals>.LambdaActionConnector.from_state6   s    ((---r%   N)
__name__
__module____qualname__r   r$   r)   staticmethodr   r   r.   )r-   r   r   s   r#   r-   r   #   s        	2	$	 	 	 	 	 		 	 	 	 	 
	., 	.c 	. 	. 	. 	. 	. 
	. 	. 	.r%   r-   )r   r/   r1   r	   )r   r   r-   s   ``@r#    register_lambda_action_connectorr3      sn    ". . . . . . . . . . . .. &*")-&t2333  r%   ConvertToNumpyConnectorc                 @    t          |           t          |          |fS r'   r   )r    r!   r"   s      r#   <lambda>r6   F   s"    W%%V$$*
 r%   N)typingr   r   r   r   ray.rllib.connectors.connectorr   r   ray.rllib.connectors.registryr	   ray.rllib.utils.annotationsr
   ray.rllib.utils.numpyr   ray.rllib.utils.typingr   r   r   r   strr3   r4   r(   r%   r#   <module>r>      sM   , , , , , , , , , , , ,        = < < < < < 3 3 3 3 3 3 2 2 2 2 2 2            ,!
,!-|TBDTTU,!	/,! ,! ,! ,!` &+$$!	
 	
 	 	   r%   