apply_to_list#
- pytorch_forecasting.utils._utils.apply_to_list(obj: list[Any] | Any, func: Callable) list[Any] | Any[source]#
Apply function to a list of objects or directly if passed value is not a list.
This is useful if the passed object could be either a list to whose elements a function needs to be applied or just an object to which to apply the function.
- Parameters:
obj (list of Any or Any) – List/tuple on whose elements to apply function, otherwise object to whom to apply function.
func (Callable) – Function to apply.
- Returns:
List of objects or object depending on function output and if input
objis of type list/tuple.- Return type:
list of Any or Any