check if torch package is installed :returns: if torch is available :rtype: bool

is_package_available(package_name: str)bool[source]

check if the package is avaliable :param package_name: the installed package name :type package_name: str


the existence of installed package

Return type



check if faster_tokenizer ia avaliable :returns: if faster_tokenizer is avaliable :rtype: bool


check if transformers package is installed :returns: if transformers is available :rtype: bool

install_package(package_name: str, version: Optional[str] = None, module_name: Optional[str] = None, cache_dir: Optional[str] = None)[source]

install the specific version of package

  • package_name (str) – the name of package

  • version (str) – the version of package

  • module_name (str) – the imported name of package

  • cache_dir (str) – cache dir

uninstall_package(package_name: str, module_name: Optional[str] = None)[source]

uninstall the pacakge from site-packages.

To remove the cache of source package module & class & method, it should:
  1. remove the source files of packages under the site-packages dir.

  2. remove the cache under the locals()

  3. remove the cache under the sys.modules


package_name (str) – the name of package

import_module(module_name: str)Optional[Type][source]

import moudle base on the model :param module_name: the name of target module :type module_name: str