from typing import Callable
from typing import Dict


def _get_valid_parameters(
        func: Callable,
        parameters: Dict) -> Dict:
    """Extract valid parameter for target function.

    Args:
        func (Callable): target function.
        parameters (Dict): candidate parameters.

    Return:
        valids (Dict): valid parameters.

    """
    return {k: parameters[k] for k in func.__code__.co_varnames if k in parameters}