import_utils#

is_paddle_available() bool[源代码]#

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

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_fast_tokenizer_available() bool[源代码]#

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

is_paddlenlp_ops_available() bool[源代码]#

check if paddlenlp_ops ia avaliable :returns: if paddlenlp_ops 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: str | None = None, module_name: str | None = None, cache_dir: str | None = 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: str | None = 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) Type | None[源代码]#

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