__init__.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_funnel": ["FunnelConfig"],
  24. "convert_funnel_original_tf_checkpoint_to_pytorch": [],
  25. "tokenization_funnel": ["FunnelTokenizer"],
  26. }
  27. try:
  28. if not is_tokenizers_available():
  29. raise OptionalDependencyNotAvailable()
  30. except OptionalDependencyNotAvailable:
  31. pass
  32. else:
  33. _import_structure["tokenization_funnel_fast"] = ["FunnelTokenizerFast"]
  34. try:
  35. if not is_torch_available():
  36. raise OptionalDependencyNotAvailable()
  37. except OptionalDependencyNotAvailable:
  38. pass
  39. else:
  40. _import_structure["modeling_funnel"] = [
  41. "FunnelBaseModel",
  42. "FunnelForMaskedLM",
  43. "FunnelForMultipleChoice",
  44. "FunnelForPreTraining",
  45. "FunnelForQuestionAnswering",
  46. "FunnelForSequenceClassification",
  47. "FunnelForTokenClassification",
  48. "FunnelModel",
  49. "FunnelPreTrainedModel",
  50. "load_tf_weights_in_funnel",
  51. ]
  52. try:
  53. if not is_tf_available():
  54. raise OptionalDependencyNotAvailable()
  55. except OptionalDependencyNotAvailable:
  56. pass
  57. else:
  58. _import_structure["modeling_tf_funnel"] = [
  59. "TFFunnelBaseModel",
  60. "TFFunnelForMaskedLM",
  61. "TFFunnelForMultipleChoice",
  62. "TFFunnelForPreTraining",
  63. "TFFunnelForQuestionAnswering",
  64. "TFFunnelForSequenceClassification",
  65. "TFFunnelForTokenClassification",
  66. "TFFunnelModel",
  67. "TFFunnelPreTrainedModel",
  68. ]
  69. if TYPE_CHECKING:
  70. from .configuration_funnel import FunnelConfig
  71. from .tokenization_funnel import FunnelTokenizer
  72. try:
  73. if not is_tokenizers_available():
  74. raise OptionalDependencyNotAvailable()
  75. except OptionalDependencyNotAvailable:
  76. pass
  77. else:
  78. from .tokenization_funnel_fast import FunnelTokenizerFast
  79. try:
  80. if not is_torch_available():
  81. raise OptionalDependencyNotAvailable()
  82. except OptionalDependencyNotAvailable:
  83. pass
  84. else:
  85. from .modeling_funnel import (
  86. FunnelBaseModel,
  87. FunnelForMaskedLM,
  88. FunnelForMultipleChoice,
  89. FunnelForPreTraining,
  90. FunnelForQuestionAnswering,
  91. FunnelForSequenceClassification,
  92. FunnelForTokenClassification,
  93. FunnelModel,
  94. FunnelPreTrainedModel,
  95. load_tf_weights_in_funnel,
  96. )
  97. try:
  98. if not is_tf_available():
  99. raise OptionalDependencyNotAvailable()
  100. except OptionalDependencyNotAvailable:
  101. pass
  102. else:
  103. from .modeling_tf_funnel import (
  104. TFFunnelBaseModel,
  105. TFFunnelForMaskedLM,
  106. TFFunnelForMultipleChoice,
  107. TFFunnelForPreTraining,
  108. TFFunnelForQuestionAnswering,
  109. TFFunnelForSequenceClassification,
  110. TFFunnelForTokenClassification,
  111. TFFunnelModel,
  112. TFFunnelPreTrainedModel,
  113. )
  114. else:
  115. import sys
  116. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)