
    &`ie	                     (   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	  edee
                   Z e j        e          Z e	d	           e            d
edefd                        Z e	d	           e            dd                        ZdS )    N)OptionalTypeVar)get_train_fn_utils)requires_train_worker)	PublicAPIT)boundalpha)	stabilitydatareturnc                 D    t                                          |           S )a]  Broadcast small (<1kb) data from the rank 0 worker to all other workers.

    Serves as a barrier, meaning that all workers must call this method before
    the training function can continue.

    Example:

        .. testcode:

            from ray.train import get_context
            from ray.train.collective import broadcast_from_rank_zero
            from ray.train.torch import TorchTrainer

            def train_func():
                ...
                if get_context().get_world_rank() == 0:
                    data = {"some_key": "some_value"}
                else:
                    data = None
                data = broadcast_from_rank_zero(data)
                ...

            trainer = TorchTrainer(train_func)
            trainer.fit()

    Args:
        data: The small (1kb) data to broadcast from the rank 0 worker to all
            other workers.

    Returns:
        The data broadcasted from the rank 0 worker.

    Raises:
        ValueError: If the data is too big.
        pickle.PicklingError: If the data is not pickleable.
        TypeError: If the data is not pickleable.
    )r   broadcast_from_rank_zero)r   s    t/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/train/collective/collectives.pyr   r      s    P 88>>>    c                  B    t                                                      S )a  Create a barrier across all workers.

    All workers must call this method before the training function can continue.

    Example:

        .. testcode:

            from ray.train import get_context
            from ray.train.collective import barrier
            from ray.train.torch import TorchTrainer

            def train_func():
                ...
                print(f"Rank {get_context().get_world_rank()} is waiting at the barrier.")
                barrier()
                print(f"Rank {get_context().get_world_rank()} has passed the barrier.")
                ...

            trainer = TorchTrainer(train_func)
            trainer.fit()
    )r   barrier r   r   r   r   9   s    2 '')))r   )r   N)loggingtypingr   r   /ray.train.v2._internal.execution.train_fn_utilsr   ray.train.v2._internal.utilr   ray.util.annotationsr   objectr   	getLogger__file__loggerr   r   r   r   r   <module>r      s&    $ $ $ $ $ $ $ $ N N N N N N = = = = = = * * * * * *GCx'((( 
	8	$	$ W&?1 &? &? &? &?  &?R W* * *  * * *r   