def METHOD_NAME(self):
    if isinstance(self.optimizer_input_str, str):
        # instantiate optimizer from string
        optimizer_class = self.OPTIMIZER_DICTIONARY[self.optimizer_input_str]
        optimizer_instance = optimizer_class(**self.optimizer_params)
        return optimizer_instance
    else:
        # Todo: check if object has the right interface
        return self.optimizer_input_str