espnet2.asr.state_spaces.utils.get_class
Less than 1 minute
espnet2.asr.state_spaces.utils.get_class
espnet2.asr.state_spaces.utils.get_class(registry, _name_)
Retrieve a class from the provided registry using its name.
This function takes a registry dictionary that maps names to class paths and returns the class corresponding to the specified name. It utilizes Hydra’s utility functions to resolve the class path.
- Parameters:
- registry (Mapping *[*str , str ]) – A mapping of names to class paths.
- _name_ (str) – The name of the class to retrieve from the registry.
- Returns: The class corresponding to the provided name from the registry.
- Return type: type
- Raises:
- KeyError – If the provided name does not exist in the registry.
- NotImplementedError – If the target path is not a string or callable.
Examples
>>> registry = {
... 'MyClass': 'path.to.MyClass',
... }
>>> MyClass = get_class(registry, 'MyClass')
>>> instance = MyClass()
NOTE
Ensure that the registry is populated with valid class paths before calling this function.