def map_structure(func, structure, args=(), kwargs={}):
    """apply func to each element in structure

    Args:
        func (callable): The function
        structure (dict, tuple, list): the structure to be mapped.

    Kwargs:
        args (tuple,list): The args to the function.
        kwargs (dict): The kwargs to the function.

    Returns: The same structure as input structure.

    """
    if structure is None:
        return None
    if isinstance(structure, (list, tuple)):
        return [func(x, *args, **kwargs) for x in structure]
    if isinstance(structure, dict):
        returns = dict()
        for key, value in structure.items():
            returns[key] = func(value, *args, **kwargs)
        return returns
    else:
        return func(structure, *args, **kwargs)