__init__.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_tf_available, is_torch_available
  16. _import_structure = {
  17. "configuration_tapas": ["TapasConfig"],
  18. "tokenization_tapas": ["TapasTokenizer"],
  19. }
  20. try:
  21. if not is_torch_available():
  22. raise OptionalDependencyNotAvailable()
  23. except OptionalDependencyNotAvailable:
  24. pass
  25. else:
  26. _import_structure["modeling_tapas"] = [
  27. "TapasForMaskedLM",
  28. "TapasForQuestionAnswering",
  29. "TapasForSequenceClassification",
  30. "TapasModel",
  31. "TapasPreTrainedModel",
  32. "load_tf_weights_in_tapas",
  33. ]
  34. try:
  35. if not is_tf_available():
  36. raise OptionalDependencyNotAvailable()
  37. except OptionalDependencyNotAvailable:
  38. pass
  39. else:
  40. _import_structure["modeling_tf_tapas"] = [
  41. "TFTapasForMaskedLM",
  42. "TFTapasForQuestionAnswering",
  43. "TFTapasForSequenceClassification",
  44. "TFTapasModel",
  45. "TFTapasPreTrainedModel",
  46. ]
  47. if TYPE_CHECKING:
  48. from .configuration_tapas import TapasConfig
  49. from .tokenization_tapas import TapasTokenizer
  50. try:
  51. if not is_torch_available():
  52. raise OptionalDependencyNotAvailable()
  53. except OptionalDependencyNotAvailable:
  54. pass
  55. else:
  56. from .modeling_tapas import (
  57. TapasForMaskedLM,
  58. TapasForQuestionAnswering,
  59. TapasForSequenceClassification,
  60. TapasModel,
  61. TapasPreTrainedModel,
  62. load_tf_weights_in_tapas,
  63. )
  64. try:
  65. if not is_tf_available():
  66. raise OptionalDependencyNotAvailable()
  67. except OptionalDependencyNotAvailable:
  68. pass
  69. else:
  70. from .modeling_tf_tapas import (
  71. TFTapasForMaskedLM,
  72. TFTapasForQuestionAnswering,
  73. TFTapasForSequenceClassification,
  74. TFTapasModel,
  75. TFTapasPreTrainedModel,
  76. )
  77. else:
  78. import sys
  79. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)