Init pickle (#12567)
* Try to pickle transformers * Deal with special objs better * Make picklable
This commit is contained in:
@@ -18,11 +18,11 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
{%- if cookiecutter.generate_tensorflow_and_pytorch == "PyTorch & TensorFlow" %}
|
||||
from ...file_utils import _BaseLazyModule, is_tf_available, is_torch_available, is_tokenizers_available
|
||||
from ...file_utils import _LazyModule, is_tf_available, is_torch_available, is_tokenizers_available
|
||||
{%- elif cookiecutter.generate_tensorflow_and_pytorch == "PyTorch" %}
|
||||
from ...file_utils import _BaseLazyModule, is_torch_available, is_tokenizers_available
|
||||
from ...file_utils import _LazyModule, is_torch_available, is_tokenizers_available
|
||||
{%- elif cookiecutter.generate_tensorflow_and_pytorch == "TensorFlow" %}
|
||||
from ...file_utils import _BaseLazyModule, is_tf_available, is_tokenizers_available
|
||||
from ...file_utils import _LazyModule, is_tf_available, is_tokenizers_available
|
||||
{% endif %}
|
||||
_import_structure = {
|
||||
"configuration_{{cookiecutter.lowercase_modelname}}": ["{{cookiecutter.uppercase_modelname}}_PRETRAINED_CONFIG_ARCHIVE_MAP", "{{cookiecutter.camelcase_modelname}}Config"],
|
||||
@@ -148,19 +148,6 @@ if TYPE_CHECKING:
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
else:
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
|
||||
class _LazyModule(_BaseLazyModule):
|
||||
"""
|
||||
Module class that surfaces all objects but only performs associated imports when the objects are requested.
|
||||
"""
|
||||
|
||||
__file__ = globals()["__file__"]
|
||||
__path__ = [os.path.dirname(__file__)]
|
||||
|
||||
def _get_module(self, module_name: str):
|
||||
return importlib.import_module("." + module_name, self.__name__)
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, _import_structure)
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)
|
||||
|
||||
Reference in New Issue
Block a user