import importlib


def str_to_class(string: str):
    """Return class from string representation."""
    idx_dot = string.rfind(".")
    if idx_dot < 0:
        module_str = "fnet.nn_modules"
        class_str = string
    else:
        module_str = string[:idx_dot]
        class_str = string[idx_dot + 1 :]
    module = importlib.import_module(module_str)
    return getattr(module, class_str)