def load_module(modulename, modulepath):
if '<STR_LIT:.>' in modulename:<EOL><INDENT>modulepackage, modulebase = modulename.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>modulepackage = '<STR_LIT>'<EOL><DEDENT>imp.acquire_lock()<EOL>try:<EOL><INDENT>if modulename not in sys.modules:<EOL><INDENT>path, name = os.path.split(modulepath)<EOL>name = os.path.splitext(name)[<NUM_LIT:0>]<EOL>handle, path, info = imp.find_module(name, [path])<EOL>try:<EOL><INDENT>module = imp.load_module(modulename, handle, path, info)<EOL>if modulepackage:<EOL><INDENT>setattr(sys.modules[modulepackage], modulebase, module)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if handle:<EOL><INDENT>handle.close()<EOL><DEDENT><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>imp.release_lock()<EOL><DEDENT>return sys.modules[modulename]<EOL>
Load a Python module from a path under a specified name.

        Parameters:
            modulename (str): Fully qualified module name, e.g. ``x.y.z``.
            modulepath (str): Filename of the module.

        Returns:
            Loaded module.