import_utils

is_torch_available()bool[源代码]

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

is_package_available(package_name: str)bool[源代码]

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

返回

the existence of installed package

返回类型

bool

is_faster_tokenizer_available()bool[源代码]

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

is_transformers_available()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)[源代码]

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)[源代码]

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][源代码]

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