__init__.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2020 The HuggingFace Team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
  16. _import_structure = {
  17. "configuration_squeezebert": [
  18. "SqueezeBertConfig",
  19. "SqueezeBertOnnxConfig",
  20. ],
  21. "tokenization_squeezebert": ["SqueezeBertTokenizer"],
  22. }
  23. try:
  24. if not is_tokenizers_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["tokenization_squeezebert_fast"] = ["SqueezeBertTokenizerFast"]
  30. try:
  31. if not is_torch_available():
  32. raise OptionalDependencyNotAvailable()
  33. except OptionalDependencyNotAvailable:
  34. pass
  35. else:
  36. _import_structure["modeling_squeezebert"] = [
  37. "SqueezeBertForMaskedLM",
  38. "SqueezeBertForMultipleChoice",
  39. "SqueezeBertForQuestionAnswering",
  40. "SqueezeBertForSequenceClassification",
  41. "SqueezeBertForTokenClassification",
  42. "SqueezeBertModel",
  43. "SqueezeBertModule",
  44. "SqueezeBertPreTrainedModel",
  45. ]
  46. if TYPE_CHECKING:
  47. from .configuration_squeezebert import (
  48. SqueezeBertConfig,
  49. SqueezeBertOnnxConfig,
  50. )
  51. from .tokenization_squeezebert import SqueezeBertTokenizer
  52. try:
  53. if not is_tokenizers_available():
  54. raise OptionalDependencyNotAvailable()
  55. except OptionalDependencyNotAvailable:
  56. pass
  57. else:
  58. from .tokenization_squeezebert_fast import SqueezeBertTokenizerFast
  59. try:
  60. if not is_torch_available():
  61. raise OptionalDependencyNotAvailable()
  62. except OptionalDependencyNotAvailable:
  63. pass
  64. else:
  65. from .modeling_squeezebert import (
  66. SqueezeBertForMaskedLM,
  67. SqueezeBertForMultipleChoice,
  68. SqueezeBertForQuestionAnswering,
  69. SqueezeBertForSequenceClassification,
  70. SqueezeBertForTokenClassification,
  71. SqueezeBertModel,
  72. SqueezeBertModule,
  73. SqueezeBertPreTrainedModel,
  74. )
  75. else:
  76. import sys
  77. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)