def METHOD_NAME(code, function_name, *args, **kwargs):
    add_type_ignores()
    module = ast.parse(code)
    exec_globals = globals().copy()
    for node in module.body:
        if isinstance(node, ast.Import):
            for alias in node.names:
                try:
                    exec(
                        f"{alias.asname or alias.name} = importlib.import_module('{alias.name}')",
                        exec_globals,
                        locals(),
                    )
                    exec_globals[alias.asname or alias.name] = importlib.import_module(
                        alias.name
                    )
                except ModuleNotFoundError as e:
                    raise ModuleNotFoundError(
                        f"Module {alias.name} not found. Please install it and try again."
                    ) from e
    function_code = next(
        node
        for node in module.body
        if isinstance(node, ast.FunctionDef) and node.name == function_name
    )
    function_code.parent = None
    code_obj = compile(
        ast.Module(body=[function_code], type_ignores=[]), "<string>", "exec"
    )
    try:
        exec(code_obj, exec_globals, locals())
    except Exception as exc:
        raise ValueError("Function string does not contain a function") from exc
    # Add the function to the exec_globals dictionary
    exec_globals[function_name] = locals()[function_name]
    return exec_globals[function_name](*args, **kwargs)