class function_configs(config):
def __init__(
self,
configs: dict | list = None,
class_name: str = None,
parameters: dict = None,
name: str = 'function_configs',
device: str = 'cpu',
*args, **kwargs
):
if configs is not None:
super().__init__(name=name, configs=configs, device=device, *args, **kwargs)
elif class_name is not None:
if not class_name.startswith('tinybig'):
class_name = class_name.split('.')[-1]
class_name = find_class_in_package(class_name=class_name)
assert class_name.startswith('tinybig')
configs = {
'function_class': class_name,
'function_parameters': parameters,
}
super().__init__(name=name, configs=configs, device=device, *args, **kwargs)
else:
super().__init__(name=name, configs=None, device=device, *args, **kwargs)
def to_instantiation(self):
if self.configs is None:
raise ValueError('The function configs object cannot be none...')
return config.instantiation_from_configs(
configs=self.configs,
device=self.device,
class_name='function_class',
parameter_name='function_parameters'
)