dgs.utils.torchtools.configure_torch_module

dgs.utils.torchtools.configure_torch_module(orig_cls: BaseMod | TorchMod, *_args, **orig_kwargs) BaseMod[source]

Decorator to decorate a class, which has to be a child of torch.nn.Module and the BaseModule! The decorator will then call BaseModule.configure_torch_model on themselves after initializing the original class.

If name is None the whole class will be used as torch.nn.Module which is going to be configured. Otherwise, the classes name attribute will be used as torch.nn.Module for configuration.

Parameters:

orig_cls – The decorated class.

Keyword Arguments:

names – The name or names of orig_cls’s attributes which contains the nn.Module that should be configured.

Raises:

ValueError – If the class is not a child of both required parent classes. Or the parameter name is set and does not exist in the class.

Returns:

The decorated class after the configuration is applied.