__init__.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # Copyright 2021 The EleutherAI and HuggingFace Teams. 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_tf_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {"configuration_gptj": ["GPTJConfig", "GPTJOnnxConfig"]}
  23. try:
  24. if not is_torch_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["modeling_gptj"] = [
  30. "GPTJForCausalLM",
  31. "GPTJForQuestionAnswering",
  32. "GPTJForSequenceClassification",
  33. "GPTJModel",
  34. "GPTJPreTrainedModel",
  35. ]
  36. try:
  37. if not is_tf_available():
  38. raise OptionalDependencyNotAvailable()
  39. except OptionalDependencyNotAvailable:
  40. pass
  41. else:
  42. _import_structure["modeling_tf_gptj"] = [
  43. "TFGPTJForCausalLM",
  44. "TFGPTJForQuestionAnswering",
  45. "TFGPTJForSequenceClassification",
  46. "TFGPTJModel",
  47. "TFGPTJPreTrainedModel",
  48. ]
  49. try:
  50. if not is_flax_available():
  51. raise OptionalDependencyNotAvailable()
  52. except OptionalDependencyNotAvailable:
  53. pass
  54. else:
  55. _import_structure["modeling_flax_gptj"] = [
  56. "FlaxGPTJForCausalLM",
  57. "FlaxGPTJModel",
  58. "FlaxGPTJPreTrainedModel",
  59. ]
  60. if TYPE_CHECKING:
  61. from .configuration_gptj import GPTJConfig, GPTJOnnxConfig
  62. try:
  63. if not is_torch_available():
  64. raise OptionalDependencyNotAvailable()
  65. except OptionalDependencyNotAvailable:
  66. pass
  67. else:
  68. from .modeling_gptj import (
  69. GPTJForCausalLM,
  70. GPTJForQuestionAnswering,
  71. GPTJForSequenceClassification,
  72. GPTJModel,
  73. GPTJPreTrainedModel,
  74. )
  75. try:
  76. if not is_tf_available():
  77. raise OptionalDependencyNotAvailable()
  78. except OptionalDependencyNotAvailable:
  79. pass
  80. else:
  81. from .modeling_tf_gptj import (
  82. TFGPTJForCausalLM,
  83. TFGPTJForQuestionAnswering,
  84. TFGPTJForSequenceClassification,
  85. TFGPTJModel,
  86. TFGPTJPreTrainedModel,
  87. )
  88. try:
  89. if not is_flax_available():
  90. raise OptionalDependencyNotAvailable()
  91. except OptionalDependencyNotAvailable:
  92. pass
  93. else:
  94. from .modeling_flax_gptj import FlaxGPTJForCausalLM, FlaxGPTJModel, FlaxGPTJPreTrainedModel
  95. else:
  96. import sys
  97. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)