import importlib


def construct_instance(fq_name, kwargs):
    """
    Constructs an instance of the class from the fully qualified name expanding
    the kwargs during construction.  e.g. fq_name(**kwargs)
    :param fq_name: The fully qualified class name.
    :param kwargs: Keyword args (a dict) to be expanded.
    :return: An instance of the class
    """

    class_data = fq_name.split(".")
    module_path = ".".join(class_data[:-1])
    class_str = class_data[-1]

    if kwargs is None:
        kwargs = {}

    module = importlib.import_module(module_path)
    return getattr(module, class_str)(**kwargs)