def import_file(name, loc):
loc = path2str(loc)<EOL>if is_python_pre_3_5:<EOL><INDENT>import imp<EOL>return imp.load_source(name, loc)<EOL><DEDENT>else:<EOL><INDENT>import importlib.util<EOL>spec = importlib.util.spec_from_file_location(name, str(loc))<EOL>module = importlib.util.module_from_spec(spec)<EOL>spec.loader.exec_module(module)<EOL>return module<EOL><DEDENT>
Import module from a file. Used to load models from a directory.

    name (unicode): Name of module to load.
    loc (unicode / Path): Path to the file.
    RETURNS: The loaded module.