__init__.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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_flax_available,
  19. is_sentencepiece_available,
  20. is_tf_available,
  21. is_tokenizers_available,
  22. is_torch_available,
  23. )
  24. _import_structure = {"configuration_xglm": ["XGLMConfig"]}
  25. try:
  26. if not is_sentencepiece_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["tokenization_xglm"] = ["XGLMTokenizer"]
  32. try:
  33. if not is_tokenizers_available():
  34. raise OptionalDependencyNotAvailable()
  35. except OptionalDependencyNotAvailable:
  36. pass
  37. else:
  38. _import_structure["tokenization_xglm_fast"] = ["XGLMTokenizerFast"]
  39. try:
  40. if not is_torch_available():
  41. raise OptionalDependencyNotAvailable()
  42. except OptionalDependencyNotAvailable:
  43. pass
  44. else:
  45. _import_structure["modeling_xglm"] = [
  46. "XGLMForCausalLM",
  47. "XGLMModel",
  48. "XGLMPreTrainedModel",
  49. ]
  50. try:
  51. if not is_flax_available():
  52. raise OptionalDependencyNotAvailable()
  53. except OptionalDependencyNotAvailable:
  54. pass
  55. else:
  56. _import_structure["modeling_flax_xglm"] = [
  57. "FlaxXGLMForCausalLM",
  58. "FlaxXGLMModel",
  59. "FlaxXGLMPreTrainedModel",
  60. ]
  61. try:
  62. if not is_tf_available():
  63. raise OptionalDependencyNotAvailable()
  64. except OptionalDependencyNotAvailable:
  65. pass
  66. else:
  67. _import_structure["modeling_tf_xglm"] = [
  68. "TFXGLMForCausalLM",
  69. "TFXGLMModel",
  70. "TFXGLMPreTrainedModel",
  71. ]
  72. if TYPE_CHECKING:
  73. from .configuration_xglm import XGLMConfig
  74. try:
  75. if not is_sentencepiece_available():
  76. raise OptionalDependencyNotAvailable()
  77. except OptionalDependencyNotAvailable:
  78. pass
  79. else:
  80. from .tokenization_xglm import XGLMTokenizer
  81. try:
  82. if not is_tokenizers_available():
  83. raise OptionalDependencyNotAvailable()
  84. except OptionalDependencyNotAvailable:
  85. pass
  86. else:
  87. from .tokenization_xglm_fast import XGLMTokenizerFast
  88. try:
  89. if not is_torch_available():
  90. raise OptionalDependencyNotAvailable()
  91. except OptionalDependencyNotAvailable:
  92. pass
  93. else:
  94. from .modeling_xglm import XGLMForCausalLM, XGLMModel, XGLMPreTrainedModel
  95. try:
  96. if not is_flax_available():
  97. raise OptionalDependencyNotAvailable()
  98. except OptionalDependencyNotAvailable:
  99. pass
  100. else:
  101. from .modeling_flax_xglm import FlaxXGLMForCausalLM, FlaxXGLMModel, FlaxXGLMPreTrainedModel
  102. try:
  103. if not is_tf_available():
  104. raise OptionalDependencyNotAvailable()
  105. except OptionalDependencyNotAvailable:
  106. pass
  107. else:
  108. from .modeling_tf_xglm import (
  109. TFXGLMForCausalLM,
  110. TFXGLMModel,
  111. TFXGLMPreTrainedModel,
  112. )
  113. else:
  114. import sys
  115. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)