__init__.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 (
  16. OptionalDependencyNotAvailable,
  17. _LazyModule,
  18. is_tf_available,
  19. is_tokenizers_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {
  23. "configuration_convbert": ["ConvBertConfig", "ConvBertOnnxConfig"],
  24. "tokenization_convbert": ["ConvBertTokenizer"],
  25. }
  26. try:
  27. if not is_tokenizers_available():
  28. raise OptionalDependencyNotAvailable()
  29. except OptionalDependencyNotAvailable:
  30. pass
  31. else:
  32. _import_structure["tokenization_convbert_fast"] = ["ConvBertTokenizerFast"]
  33. try:
  34. if not is_torch_available():
  35. raise OptionalDependencyNotAvailable()
  36. except OptionalDependencyNotAvailable:
  37. pass
  38. else:
  39. _import_structure["modeling_convbert"] = [
  40. "ConvBertForMaskedLM",
  41. "ConvBertForMultipleChoice",
  42. "ConvBertForQuestionAnswering",
  43. "ConvBertForSequenceClassification",
  44. "ConvBertForTokenClassification",
  45. "ConvBertLayer",
  46. "ConvBertModel",
  47. "ConvBertPreTrainedModel",
  48. "load_tf_weights_in_convbert",
  49. ]
  50. try:
  51. if not is_tf_available():
  52. raise OptionalDependencyNotAvailable()
  53. except OptionalDependencyNotAvailable:
  54. pass
  55. else:
  56. _import_structure["modeling_tf_convbert"] = [
  57. "TFConvBertForMaskedLM",
  58. "TFConvBertForMultipleChoice",
  59. "TFConvBertForQuestionAnswering",
  60. "TFConvBertForSequenceClassification",
  61. "TFConvBertForTokenClassification",
  62. "TFConvBertLayer",
  63. "TFConvBertModel",
  64. "TFConvBertPreTrainedModel",
  65. ]
  66. if TYPE_CHECKING:
  67. from .configuration_convbert import ConvBertConfig, ConvBertOnnxConfig
  68. from .tokenization_convbert import ConvBertTokenizer
  69. try:
  70. if not is_tokenizers_available():
  71. raise OptionalDependencyNotAvailable()
  72. except OptionalDependencyNotAvailable:
  73. pass
  74. else:
  75. from .tokenization_convbert_fast import ConvBertTokenizerFast
  76. try:
  77. if not is_torch_available():
  78. raise OptionalDependencyNotAvailable()
  79. except OptionalDependencyNotAvailable:
  80. pass
  81. else:
  82. from .modeling_convbert import (
  83. ConvBertForMaskedLM,
  84. ConvBertForMultipleChoice,
  85. ConvBertForQuestionAnswering,
  86. ConvBertForSequenceClassification,
  87. ConvBertForTokenClassification,
  88. ConvBertLayer,
  89. ConvBertModel,
  90. ConvBertPreTrainedModel,
  91. load_tf_weights_in_convbert,
  92. )
  93. try:
  94. if not is_tf_available():
  95. raise OptionalDependencyNotAvailable()
  96. except OptionalDependencyNotAvailable:
  97. pass
  98. else:
  99. from .modeling_tf_convbert import (
  100. TFConvBertForMaskedLM,
  101. TFConvBertForMultipleChoice,
  102. TFConvBertForQuestionAnswering,
  103. TFConvBertForSequenceClassification,
  104. TFConvBertForTokenClassification,
  105. TFConvBertLayer,
  106. TFConvBertModel,
  107. TFConvBertPreTrainedModel,
  108. )
  109. else:
  110. import sys
  111. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)