def class_from_module_path(module_path: Text, lookup_path: Optional[Text]=None) -> Type:
    'Given the module name and path of a class, tries to retrieve the class.\n\n    The loaded class can be used to instantiate new objects.\n\n    Args:\n        module_path: either an absolute path to a Python class,\n                     or the name of the class in the local / global scope.\n        lookup_path: a path where to load the class from, if it cannot\n                     be found in the local / global scope.\n\n    Returns:\n        a Python class\n\n    Raises:\n        ImportError, in case the Python class cannot be found.\n        RasaException, in case the imported result is something other than a class\n    '
    klass = None
    if ('.' in module_path):
        (module_name, _, class_name) = module_path.rpartition('.')
        m = importlib.import_module(module_name)
        klass = getattr(m, class_name, None)
    elif lookup_path:
        m = importlib.import_module(lookup_path)
        klass = getattr(m, module_path, None)
    if (klass is None):
        raise ImportError(f'Cannot retrieve class from path {module_path}.')
    if (not inspect.isclass(klass)):
        raise RasaException(f'`class_from_module_path()` is expected to return a class, but for {module_path} we got a {type(klass)}.')
    return klass
Given the module name and path of a class, tries to retrieve the class.

The loaded class can be used to instantiate new objects.

Args:
    module_path: either an absolute path to a Python class,
                 or the name of the class in the local / global scope.
    lookup_path: a path where to load the class from, if it cannot
                 be found in the local / global scope.

Returns:
    a Python class

Raises:
    ImportError, in case the Python class cannot be found.
    RasaException, in case the imported result is something other than a class
def class_from_module_path(module_path: Text, lookup_path: Optional[Text]=None) -> Type:
    'Given the module name and path of a class, tries to retrieve the class.\n\n    The loaded class can be used to instantiate new objects.\n\n    Args:\n        module_path: either an absolute path to a Python class,\n                     or the name of the class in the local / global scope.\n        lookup_path: a path where to load the class from, if it cannot\n                     be found in the local / global scope.\n\n    Returns:\n        a Python class\n\n    Raises:\n        ImportError, in case the Python class cannot be found.\n        RasaException, in case the imported result is something other than a class\n    '
    klass = None
    if ('.' in module_path):
        (module_name, _, class_name) = module_path.rpartition('.')
        m = importlib.import_module(module_name)
        klass = getattr(m, class_name, None)
    elif lookup_path:
        m = importlib.import_module(lookup_path)
        klass = getattr(m, module_path, None)
    if (klass is None):
        raise ImportError(f'Cannot retrieve class from path {module_path}.')
    if (not inspect.isclass(klass)):
        raise RasaException(f'`class_from_module_path()` is expected to return a class, but for {module_path} we got a {type(klass)}.')
    return klass