from typing import Dict
from typing import Tuple
from typing import Optional


def _get_function_meta(function: Dict) -> Tuple[Optional[str], str, dict]:
    """Get the metadata for the module, function_name and parameters."""
    module_path = None

    if isinstance(function, dict):
        module_function = next(iter(function))
        function_parameters = next(iter(function.values()))
    elif isinstance(function, str):
        module_function = function
        function_parameters = {}
    else:
        raise ValueError(f"Could not process function {function}")

    if "." in module_function:
        module_path, module_function = module_function.rsplit(".", 1)

    return module_path, module_function, function_parameters