ray.rllib.core.rl_module.multi_rl_module.MultiRLModule.foreach_module#

MultiRLModule.foreach_module(func: Callable[[str, RLModule, Any | None], T], *, return_dict: bool = False, **kwargs) List[T] | Dict[str, T][source]#

Calls the given function with each (module_id, module).

Parameters:
  • func – The function to call with each (module_id, module) tuple.

  • return_dict – Whether to return a dict mapping ModuleID to the individual module’s return values of calling func. If False (default), return a list.

Returns:

The list of return values of all calls to func([module_id, module, **kwargs]) or a dict (if return_dict=True) mapping ModuleIDs to the respective models’ return values.