from importlib.machinery import SourceFileLoader


def load_func(path_to_function_file):
    """
    Parse optimization function

    Args:
        path_to_function_file (str): Path to the file, in which the function
            with the name 'opt_func' is

    Returns:
        optimize function
    """
    loader = SourceFileLoader('opt_func', path_to_function_file)
    module = loader.load_module()
    function = getattr(module, 'opt_func')
    return function