espnet2.utils.get_default_kwargs.get_default_kwargs
Less than 1 minute
espnet2.utils.get_default_kwargs.get_default_kwargs
espnet2.utils.get_default_kwargs.get_default_kwargs(func)
Get the default values of the input function.
This function inspects the given function’s parameters and retrieves the default values for each parameter. It also checks whether these values are serializable to YAML format. If a value is not serializable, it is replaced with a marker object.
- Parameters:func (callable) – The function from which to retrieve default parameter values.
- Returns: A dictionary containing the parameter names as keys and their : corresponding default values. Non-serializable values are excluded from the returned dictionary.
- Return type: dict
- Raises:Invalid – A marker object indicating a non-serializable value.
Examples
>>> def func(a, b=3):
... pass
>>> get_default_kwargs(func)
{'b': 3}
NOTE
This function uses the inspect module to analyze the function’s signature and determine the default values.