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 (Callable[[str, RLModule, Any | None], T]) – The function to call with each (module_id, module) tuple.

  • return_dict (bool) – 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.

Return type:

List[T] | Dict[str, T]