__init__.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright 2021 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_led": ["LEDConfig"],
  24. "tokenization_led": ["LEDTokenizer"],
  25. }
  26. try:
  27. if not is_tokenizers_available():
  28. raise OptionalDependencyNotAvailable()
  29. except OptionalDependencyNotAvailable:
  30. pass
  31. else:
  32. _import_structure["tokenization_led_fast"] = ["LEDTokenizerFast"]
  33. try:
  34. if not is_torch_available():
  35. raise OptionalDependencyNotAvailable()
  36. except OptionalDependencyNotAvailable:
  37. pass
  38. else:
  39. _import_structure["modeling_led"] = [
  40. "LEDForConditionalGeneration",
  41. "LEDForQuestionAnswering",
  42. "LEDForSequenceClassification",
  43. "LEDModel",
  44. "LEDPreTrainedModel",
  45. ]
  46. try:
  47. if not is_tf_available():
  48. raise OptionalDependencyNotAvailable()
  49. except OptionalDependencyNotAvailable:
  50. pass
  51. else:
  52. _import_structure["modeling_tf_led"] = ["TFLEDForConditionalGeneration", "TFLEDModel", "TFLEDPreTrainedModel"]
  53. if TYPE_CHECKING:
  54. from .configuration_led import LEDConfig
  55. from .tokenization_led import LEDTokenizer
  56. try:
  57. if not is_tokenizers_available():
  58. raise OptionalDependencyNotAvailable()
  59. except OptionalDependencyNotAvailable:
  60. pass
  61. else:
  62. from .tokenization_led_fast import LEDTokenizerFast
  63. try:
  64. if not is_torch_available():
  65. raise OptionalDependencyNotAvailable()
  66. except OptionalDependencyNotAvailable:
  67. pass
  68. else:
  69. from .modeling_led import (
  70. LEDForConditionalGeneration,
  71. LEDForQuestionAnswering,
  72. LEDForSequenceClassification,
  73. LEDModel,
  74. LEDPreTrainedModel,
  75. )
  76. try:
  77. if not is_tf_available():
  78. raise OptionalDependencyNotAvailable()
  79. except OptionalDependencyNotAvailable:
  80. pass
  81. else:
  82. from .modeling_tf_led import TFLEDForConditionalGeneration, TFLEDModel, TFLEDPreTrainedModel
  83. else:
  84. import sys
  85. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)