from typing import Callable
from typing import Dict


def add_features(transform: Callable[[Dict], Dict], x: Dict) -> Dict:
    """
    Takes the input, passes it to a transformation and merge the original
    input with the result of the transformation, can be used to
    augment data in the batch.

    .. note::
        transform type and input type must match.

    Parameters
    ----------
    transform: Callable
        transformation applied
    x: Dict
        data to transform

    Example
    -------

    >>> add_features(lambda _: {'y': 1}, {'a': 2})
    {'a': 2, 'y': 1}
    """
    results = transform(x)
    if isinstance(results, dict) and isinstance(x, dict):
        return dict(x, **results)
    else:
        raise ValueError("dictionaries supported only")