class_docstr: In PaddleHub, Module represents an executable module, which usually a pre-trained model that can be used for end-to-end
  prediction, such as a face detection model or a lexical analysis model, or a pre-trained model that requires finetuning,
  such as BERT/ERNIE. When loading a Module with a specified name, if the Module does not exist locally, PaddleHub will
  automatically request the server or the specified Git source to download the resource.
  
  Args:
      name(str): Module name.
      directory(str|optional): Directory of the module to be loaded, only takes effect when the `name` is not specified.
      version(str|optional): The version limit of the module, only takes effect when the `name` is specified. When the local
          Module does not meet the specified version conditions, PaddleHub will re-request the server to download the
          appropriate Module. Default to None, This means that the local Module will be used. If the Module does not exist,
          PaddleHub will download the latest version available from the server according to the usage environment.
      source(str|optional): Url of a git repository. If this parameter is specified, PaddleHub will no longer download the
          specified Module from the default server, but will look for it in the specified repository. Default to None.
      update(bool|optional): Whether to update the locally cached git repository, only takes effect when the `source` is
          specified. Default to False.
      branch(str|optional): The branch of the specified git repository. Default to None.
      ignore_env_mismatch(bool|optional): Whether to ignore the environment mismatch when installing the Module. Default to
          False.
class_docstr_tok: ["In","PaddleHub",",","Module","represents","an","executable","module",",","which","usually","a","pre-trained","model","that","can","be","used","for","end-to-end","prediction",",","such","as","a","face","detection","model","or","a","lexical","analysis","model",",","or","a","pre-trained","model","that","requires","finetuning",",","such","as","BERT\/ERNIE",".","When","loading","a","Module","with","a","specified","name",",","if","the","Module","does","not","exist","locally",",","PaddleHub","will","automatically","request","the","server","or","the","specified","Git","source","to","download","the","resource",".","Args",":","name","(","str",")",":","Module","name",".","directory","(","str|optional",")",":","Directory","of","the","module","to","be","loaded",",","only","takes","effect","when","the","`","name","`","is","not","specified",".","version","(","str|optional",")",":","The","version","limit","of","the","module",",","only","takes","effect","when","the","`","name","`","is","specified",".","When","the","local","Module","does","not","meet","the","specified","version","conditions",",","PaddleHub","will","re-request","the","server","to","download","the","appropriate","Module",".","Default","to","None",",","This","means","that","the","local","Module","will","be","used",".","If","the","Module","does","not","exist",",","PaddleHub","will","download","the","latest","version","available","from","the","server","according","to","the","usage","environment",".","source","(","str|optional",")",":","Url","of","a","git","repository",".","If","this","parameter","is","specified",",","PaddleHub","will","no","longer","download","the","specified","Module","from","the","default","server",",","but","will","look","for","it","in","the","specified","repository",".","Default","to","None",".","update","(","bool|optional",")",":","Whether","to","update","the","locally","cached","git","repository",",","only","takes","effect","when","the","`","source","`","is","specified",".","Default","to","False",".","branch","(","str|optional",")",":","The","branch","of","the","specified","git","repository",".","Default","to","None",".","ignore_env_mismatch","(","bool|optional",")",":","Whether","to","ignore","the","environment","mismatch","when","installing","the","Module",".","Default","to","False","."]
docstr: Load the Module object defined in the specified directory.
docstr_tok: ["Load","the","Module","object","defined","in","the","specified","directory","."]
code: def load(cls, directory: str) -> Generic:
      """Load the Module object defined in the specified directory."""
      if directory.endswith(os.sep):
          directory = directory[:-1]
  
      # If the module description file existed, try to load as ModuleV1
      desc_file = os.path.join(directory, "module_desc.pb")
      if os.path.exists(desc_file):
          return ModuleV1.load(directory)
  
      basename = os.path.split(directory)[-1]
      dirname = os.path.join(*list(os.path.split(directory)[:-1]))
      py_module = utils.load_py_module(
          dirname, "{}.module".format(basename)
      )
  
      for _item, _cls in inspect.getmembers(py_module, inspect.isclass):
          _item = py_module.__dict__[_item]
          if hasattr(_item, "_hook_by_hub") and issubclass(
              _item, RunModule
          ):
              user_module_cls = _item
              break
      else:
          raise InvalidHubModule(directory)
  
      user_module_cls.directory = directory
  
      source_info_file = os.path.join(directory, "_source_info.yaml")
      if os.path.exists(source_info_file):
          info = parser.yaml_parser.parse(source_info_file)
          user_module_cls.source = info.get("source", "")
          user_module_cls.branch = info.get("branch", "")
      else:
          user_module_cls.source = ""
          user_module_cls.branch = ""
  
      # In the case of multiple cards, the following code can set each process to use the correct place.
      if issubclass(user_module_cls, paddle.nn.Layer):
          place = paddle.get_device().split(":")[0]
          paddle.set_device(place)
  
      return user_module_cls
  
imports: import ast
  import builtins
  import codecs
  import inspect
  import os
  import re
  import sys
  from typing import Callable
  from typing import Generic
  from typing import List
  from typing import Optional
  from typing import Union
  import paddle
  import paddle2onnx
  from easydict import EasyDict
  from paddlehub.compat import paddle_utils
  from paddlehub.compat.module.module_v1 import ModuleV1
  from paddlehub.utils import log
  from paddlehub.utils import parser
  from paddlehub.utils import utils
label_desc: Use image node_id 2 for calling the Module obj's underlying member method code with example usage: obj.load(cls, directory) and returns: user_module_cls, ModuleV1